From 6bca60ca97310c5b7de139053b26774a9d1cf24c Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 19 Apr 2023 07:36:46 +0200 Subject: [PATCH] neon: Move storage initialization to blocs --- packages/neon/neon/lib/neon.dart | 3 +-- packages/neon/neon/lib/src/blocs/accounts.dart | 3 +-- packages/neon/neon/lib/src/utils/global_options.dart | 5 +++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/neon/neon/lib/neon.dart b/packages/neon/neon/lib/neon.dart index 26ecc766..5a380332 100644 --- a/packages/neon/neon/lib/neon.dart +++ b/packages/neon/neon/lib/neon.dart @@ -130,14 +130,13 @@ Future runNeon({ final packageInfo = await PackageInfo.fromPlatform(); final globalOptions = GlobalOptions( - AppStorage('global', sharedPreferences), + sharedPreferences, packageInfo, ); final accountsBloc = AccountsBloc( requestManager, platform, - AppStorage('accounts', sharedPreferences), sharedPreferences, globalOptions, allAppImplementations, diff --git a/packages/neon/neon/lib/src/blocs/accounts.dart b/packages/neon/neon/lib/src/blocs/accounts.dart index b542cfd4..9bebe6d7 100644 --- a/packages/neon/neon/lib/src/blocs/accounts.dart +++ b/packages/neon/neon/lib/src/blocs/accounts.dart @@ -16,7 +16,6 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState AccountsBloc( this._requestManager, this._platform, - this._storage, this._sharedPreferences, this._globalOptions, this._allAppImplementations, @@ -53,7 +52,7 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState final RequestManager _requestManager; final NeonPlatform _platform; - final AppStorage _storage; + late final AppStorage _storage = AppStorage('accounts', _sharedPreferences); final SharedPreferences _sharedPreferences; final GlobalOptions _globalOptions; final List _allAppImplementations; diff --git a/packages/neon/neon/lib/src/utils/global_options.dart b/packages/neon/neon/lib/src/utils/global_options.dart index da790dfb..926fad3b 100644 --- a/packages/neon/neon/lib/src/utils/global_options.dart +++ b/packages/neon/neon/lib/src/utils/global_options.dart @@ -4,7 +4,7 @@ const unifiedPushNextPushID = 'org.unifiedpush.distributor.nextpush'; class GlobalOptions { GlobalOptions( - this._storage, + this._sharedPreferences, this._packageInfo, ) { themeMode.stream.listen((final value) { @@ -47,7 +47,8 @@ class GlobalOptions { }); } - final AppStorage _storage; + final SharedPreferences _sharedPreferences; + late final AppStorage _storage = AppStorage('global', _sharedPreferences); final PackageInfo _packageInfo; final _themeOLEDAsDarkEnabledSubject = BehaviorSubject(); final _pushNotificationsEnabledEnabledSubject = BehaviorSubject();