Skip to content

Commit

Permalink
fix(app): fix hot restart with activeDrugs and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tamara-slosarek authored and tamslo committed Nov 28, 2023
1 parent 1c18e81 commit fd3f152
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/lib/common/models/userdata/userdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,15 @@ class UserData {
}
}

// Wrapper of UserData.instance.activeDrugNames that manages changes; used to
// notify inactive tabs in case of changes. Should be refacored to ensure
// consistent use accross the app, see
// https://github.com/hpi-dhc/PharMe/issues/680
class ActiveDrugs extends ChangeNotifier {
List<String> names = [];
ActiveDrugs() {
names = UserData.instance.activeDrugNames ?? [];
}
late List<String> names;

Future<void> _preserveAndNotify() async {
UserData.instance.activeDrugNames = names;
Expand Down Expand Up @@ -207,6 +214,10 @@ class ActiveDrugs extends ChangeNotifier {
bool contains(String drugName) {
return names.contains(drugName);
}

bool isNotEmpty() {
return names.isNotEmpty;
}
}

/// Initializes the user's data by registering all necessary adapters and
Expand Down

0 comments on commit fd3f152

Please sign in to comment.