File tree 7 files changed +15
-20
lines changed
7 files changed +15
-20
lines changed Original file line number Diff line number Diff line change @@ -86,12 +86,6 @@ abstract class GlobalStore extends ChangeNotifier {
86
86
/// subscribes to changes in the [GlobalSettingsStore] .
87
87
final GlobalSettingsStore settings;
88
88
89
- /// Update the global settings in the store.
90
- // TODO inline this out
91
- Future <void > updateGlobalSettings (GlobalSettingsCompanion data) async {
92
- await settings.update (data);
93
- }
94
-
95
89
/// A cache of the [Accounts] table in the underlying data store.
96
90
final Map <int , Account > _accounts;
97
91
Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ class _ThemeSetting extends StatelessWidget {
33
33
const _ThemeSetting ();
34
34
35
35
void _handleChange (BuildContext context, ThemeSetting ? newThemeSetting) {
36
- GlobalStoreWidget .of (context).updateGlobalSettings (
36
+ final globalSettings = GlobalStoreWidget .settingsOf (context);
37
+ globalSettings.update (
37
38
GlobalSettingsCompanion (themeSetting: Value (newThemeSetting)));
38
39
}
39
40
@@ -60,10 +61,10 @@ class _BrowserPreferenceSetting extends StatelessWidget {
60
61
const _BrowserPreferenceSetting ();
61
62
62
63
void _handleChange (BuildContext context, bool newOpenLinksWithInAppBrowser) {
63
- GlobalStoreWidget .of (context). updateGlobalSettings (
64
- GlobalSettingsCompanion (browserPreference: Value (
65
- newOpenLinksWithInAppBrowser ? BrowserPreference .inApp
66
- : BrowserPreference .external )));
64
+ final globalSettings = GlobalStoreWidget .settingsOf (context);
65
+ globalSettings. update ( GlobalSettingsCompanion (browserPreference: Value (
66
+ newOpenLinksWithInAppBrowser ? BrowserPreference .inApp
67
+ : BrowserPreference .external )));
67
68
}
68
69
69
70
@override
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ void main() {
37
37
final globalStore = eg.globalStore ();
38
38
check (globalStore).settings.themeSetting.equals (null );
39
39
40
- await globalStore.updateGlobalSettings (
40
+ await globalStore.settings. update (
41
41
GlobalSettingsCompanion (themeSetting: Value (ThemeSetting .dark)));
42
42
check (globalStore).settings.themeSetting.equals (ThemeSetting .dark);
43
43
});
@@ -48,7 +48,7 @@ void main() {
48
48
globalStore.settings.addListener (() => notifyCount++ );
49
49
check (notifyCount).equals (0 );
50
50
51
- await globalStore.updateGlobalSettings (
51
+ await globalStore.settings. update (
52
52
GlobalSettingsCompanion (themeSetting: Value (ThemeSetting .light)));
53
53
check (notifyCount).equals (1 );
54
54
});
Original file line number Diff line number Diff line change @@ -801,7 +801,7 @@ void main() {
801
801
}, variant: const TargetPlatformVariant ({TargetPlatform .android, TargetPlatform .iOS}));
802
802
803
803
testWidgets ('follow browser preference setting to open URL' , (tester) async {
804
- await testBinding.globalStore.updateGlobalSettings (
804
+ await testBinding.globalStore.settings. update (
805
805
GlobalSettingsData (
806
806
browserPreference: BrowserPreference .inApp).toCompanion (false ));
807
807
await prepare (tester,
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ void main() {
51
51
testWidgets ('smoke' , (tester) async {
52
52
debugBrightnessOverride = Brightness .light;
53
53
54
- await testBinding.globalStore.updateGlobalSettings (
54
+ await testBinding.globalStore.settings. update (
55
55
GlobalSettingsData (themeSetting: ThemeSetting .light).toCompanion (false ));
56
56
await prepare (tester);
57
57
final element = tester.element (find.byType (SettingsPage ));
@@ -101,7 +101,7 @@ void main() {
101
101
}
102
102
103
103
testWidgets ('smoke' , (tester) async {
104
- await testBinding.globalStore.updateGlobalSettings (
104
+ await testBinding.globalStore.settings. update (
105
105
GlobalSettingsData (
106
106
browserPreference: BrowserPreference .external ).toCompanion (false ));
107
107
await prepare (tester);
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ void main() {
106
106
107
107
testWidgets ('GlobalStoreWidget.settingsOf updates on settings update' , (tester) async {
108
108
addTearDown (testBinding.reset);
109
- await testBinding.globalStore.updateGlobalSettings (
109
+ await testBinding.globalStore.settings. update (
110
110
GlobalSettingsCompanion (themeSetting: Value (ThemeSetting .dark)));
111
111
112
112
ThemeSetting ? themeSetting;
@@ -120,7 +120,7 @@ void main() {
120
120
await tester.pump ();
121
121
check (themeSetting).equals (ThemeSetting .dark);
122
122
123
- await testBinding.globalStore.updateGlobalSettings (
123
+ await testBinding.globalStore.settings. update (
124
124
GlobalSettingsCompanion (themeSetting: Value (ThemeSetting .light)));
125
125
await tester.pump ();
126
126
check (themeSetting).equals (ThemeSetting .light);
Original file line number Diff line number Diff line change @@ -134,11 +134,11 @@ void main() {
134
134
final element = tester.element (find.byType (Placeholder ));
135
135
check (zulipThemeData (element)).brightness.equals (Brightness .light);
136
136
137
- await testBinding.globalStore.updateGlobalSettings (
137
+ await testBinding.globalStore.settings. update (
138
138
const GlobalSettingsCompanion (themeSetting: Value (ThemeSetting .dark)));
139
139
check (zulipThemeData (element)).brightness.equals (Brightness .dark);
140
140
141
- await testBinding.globalStore.updateGlobalSettings (
141
+ await testBinding.globalStore.settings. update (
142
142
const GlobalSettingsCompanion (themeSetting: Value (null )));
143
143
check (zulipThemeData (element)).brightness.equals (Brightness .light);
144
144
});
You can’t perform that action at this time.
0 commit comments