Browse Source

Merge pull request #256 from provokateurin/refactor/storage-initialization

neon: Move storage initialization to blocs
pull/261/head
Kate 2 years ago committed by GitHub
parent
commit
347f2a90d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      packages/neon/neon/lib/neon.dart
  2. 3
      packages/neon/neon/lib/src/blocs/accounts.dart
  3. 5
      packages/neon/neon/lib/src/utils/global_options.dart

3
packages/neon/neon/lib/neon.dart

@ -130,14 +130,13 @@ Future runNeon({
final packageInfo = await PackageInfo.fromPlatform(); final packageInfo = await PackageInfo.fromPlatform();
final globalOptions = GlobalOptions( final globalOptions = GlobalOptions(
AppStorage('global', sharedPreferences), sharedPreferences,
packageInfo, packageInfo,
); );
final accountsBloc = AccountsBloc( final accountsBloc = AccountsBloc(
requestManager, requestManager,
platform, platform,
AppStorage('accounts', sharedPreferences),
sharedPreferences, sharedPreferences,
globalOptions, globalOptions,
allAppImplementations, allAppImplementations,

3
packages/neon/neon/lib/src/blocs/accounts.dart

@ -16,7 +16,6 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
AccountsBloc( AccountsBloc(
this._requestManager, this._requestManager,
this._platform, this._platform,
this._storage,
this._sharedPreferences, this._sharedPreferences,
this._globalOptions, this._globalOptions,
this._allAppImplementations, this._allAppImplementations,
@ -53,7 +52,7 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
final RequestManager _requestManager; final RequestManager _requestManager;
final NeonPlatform _platform; final NeonPlatform _platform;
final AppStorage _storage; late final AppStorage _storage = AppStorage('accounts', _sharedPreferences);
final SharedPreferences _sharedPreferences; final SharedPreferences _sharedPreferences;
final GlobalOptions _globalOptions; final GlobalOptions _globalOptions;
final List<AppImplementation> _allAppImplementations; final List<AppImplementation> _allAppImplementations;

5
packages/neon/neon/lib/src/utils/global_options.dart

@ -4,7 +4,7 @@ const unifiedPushNextPushID = 'org.unifiedpush.distributor.nextpush';
class GlobalOptions { class GlobalOptions {
GlobalOptions( GlobalOptions(
this._storage, this._sharedPreferences,
this._packageInfo, this._packageInfo,
) { ) {
themeMode.stream.listen((final value) { 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 PackageInfo _packageInfo;
final _themeOLEDAsDarkEnabledSubject = BehaviorSubject<bool>(); final _themeOLEDAsDarkEnabledSubject = BehaviorSubject<bool>();
final _pushNotificationsEnabledEnabledSubject = BehaviorSubject<bool>(); final _pushNotificationsEnabledEnabledSubject = BehaviorSubject<bool>();

Loading…
Cancel
Save