@@ -58,25 +58,22 @@ abstract class GlobalStore extends ChangeNotifier {
58
58
required GlobalSettingsData globalSettings,
59
59
required Iterable <Account > accounts,
60
60
})
61
- : _globalSettings = globalSettings,
61
+ : settingsNotifier = GlobalSettingsStore (data : globalSettings) ,
62
62
_accounts = Map .fromEntries (accounts.map ((a) => MapEntry (a.id, a)));
63
63
64
- // TODO use this as the actual store
65
- final GlobalSettingsStore settingsNotifier = GlobalSettingsStore ();
64
+ final GlobalSettingsStore settingsNotifier; // TODO rename as the store
66
65
67
66
/// A cache of the [GlobalSettingsData] singleton in the underlying data store.
68
67
///
69
68
/// To be notified for changes to this value, subscribe to [settingsNotifier]
70
69
/// (usually by calling [GlobalStoreWidget.settingsOf] ).
71
70
/// The [GlobalStore] itself will not notify its own listeners.
72
- GlobalSettingsData get globalSettings => _globalSettings;
73
- GlobalSettingsData _globalSettings;
71
+ GlobalSettingsData get globalSettings => settingsNotifier.data;
74
72
75
73
/// Update the global settings in the store.
76
74
Future <void > updateGlobalSettings (GlobalSettingsCompanion data) async {
77
75
await doUpdateGlobalSettings (data);
78
- _globalSettings = _globalSettings.copyWithCompanion (data);
79
- settingsNotifier.markUpdated ();
76
+ settingsNotifier.update (data);
80
77
}
81
78
82
79
/// Update the global settings in the underlying data store.
0 commit comments