From 9321f1f6d71393b13d5e7b21b90edeaae828b2ff Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Tue, 29 Aug 2023 17:13:33 +0200 Subject: [PATCH] feat(neon): make AppStorage constant Signed-off-by: Nikolas Rimikis --- packages/neon/neon/lib/src/blocs/accounts.dart | 2 +- packages/neon/neon/lib/src/blocs/first_launch.dart | 2 +- packages/neon/neon/lib/src/blocs/push_notifications.dart | 2 +- packages/neon/neon/lib/src/settings/models/storage.dart | 2 +- packages/neon/neon/lib/src/utils/global_options.dart | 2 +- packages/neon/neon/lib/src/utils/push_utils.dart | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/neon/neon/lib/src/blocs/accounts.dart b/packages/neon/neon/lib/src/blocs/accounts.dart index 10605cea..76a93fe5 100644 --- a/packages/neon/neon/lib/src/blocs/accounts.dart +++ b/packages/neon/neon/lib/src/blocs/accounts.dart @@ -94,7 +94,7 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState } } - late final AppStorage _storage = AppStorage('accounts'); + late final AppStorage _storage = const AppStorage('accounts'); final GlobalOptions _globalOptions; final Iterable _allAppImplementations; final _keyLastUsedAccount = 'last-used-account'; diff --git a/packages/neon/neon/lib/src/blocs/first_launch.dart b/packages/neon/neon/lib/src/blocs/first_launch.dart index fef5589c..6879ac22 100644 --- a/packages/neon/neon/lib/src/blocs/first_launch.dart +++ b/packages/neon/neon/lib/src/blocs/first_launch.dart @@ -16,7 +16,7 @@ abstract class FirstLaunchBlocStates { class FirstLaunchBloc extends Bloc implements FirstLaunchBlocEvents, FirstLaunchBlocStates { FirstLaunchBloc({ final bool disabled = false, - }) : _storage = AppStorage(_keyFirstLaunch) { + }) : _storage = const AppStorage(_keyFirstLaunch) { if (!disabled && !_storage.containsKey(_keyFirstLaunch)) { onFirstLaunch.add(null); unawaited(_storage.setBool(_keyFirstLaunch, false)); diff --git a/packages/neon/neon/lib/src/blocs/push_notifications.dart b/packages/neon/neon/lib/src/blocs/push_notifications.dart index c25a71f1..7e3c6698 100644 --- a/packages/neon/neon/lib/src/blocs/push_notifications.dart +++ b/packages/neon/neon/lib/src/blocs/push_notifications.dart @@ -37,7 +37,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents, } final AccountsBloc _accountsBloc; - late final _storage = AppStorage(AppIDs.notifications); + late final _storage = const AppStorage(AppIDs.notifications); final GlobalOptions _globalOptions; final _notificationsController = StreamController(); diff --git a/packages/neon/neon/lib/src/settings/models/storage.dart b/packages/neon/neon/lib/src/settings/models/storage.dart index ab3ec136..2169c182 100644 --- a/packages/neon/neon/lib/src/settings/models/storage.dart +++ b/packages/neon/neon/lib/src/settings/models/storage.dart @@ -18,7 +18,7 @@ abstract interface class SettingsStorage { @immutable @internal class AppStorage implements SettingsStorage { - AppStorage(this._id); + const AppStorage(this._id); final String _id; diff --git a/packages/neon/neon/lib/src/utils/global_options.dart b/packages/neon/neon/lib/src/utils/global_options.dart index d6b319f1..9319b927 100644 --- a/packages/neon/neon/lib/src/utils/global_options.dart +++ b/packages/neon/neon/lib/src/utils/global_options.dart @@ -49,7 +49,7 @@ class GlobalOptions { } } - late final AppStorage _storage = AppStorage('global'); + late final AppStorage _storage = const AppStorage('global'); final PackageInfo _packageInfo; late final _distributorsMap = { diff --git a/packages/neon/neon/lib/src/utils/push_utils.dart b/packages/neon/neon/lib/src/utils/push_utils.dart index 1588dbce..b3bce24f 100644 --- a/packages/neon/neon/lib/src/utils/push_utils.dart +++ b/packages/neon/neon/lib/src/utils/push_utils.dart @@ -72,7 +72,7 @@ class PushUtils { ); await AppStorage.init(); - final keypair = await loadRSAKeypair(AppStorage(AppIDs.notifications)); + final keypair = await loadRSAKeypair(const AppStorage(AppIDs.notifications)); for (final message in Uri(query: utf8.decode(messages)).queryParameters.values) { final data = json.decode(message) as Map; @@ -98,7 +98,7 @@ class PushUtils { NotificationsNotification? notification; AndroidBitmap? largeIconBitmap; try { - accounts = loadAccounts(AppStorage('accounts')); + accounts = loadAccounts(const AppStorage('accounts')); account = accounts.tryFind(instance); if (account != null) { notification =