Browse Source

feat(neon): make AppStorage constant

Signed-off-by: Nikolas Rimikis <rimikis.nikolas@gmail.com>
pull/674/head
Nikolas Rimikis 1 year ago
parent
commit
9321f1f6d7
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/neon/neon/lib/src/blocs/accounts.dart
  2. 2
      packages/neon/neon/lib/src/blocs/first_launch.dart
  3. 2
      packages/neon/neon/lib/src/blocs/push_notifications.dart
  4. 2
      packages/neon/neon/lib/src/settings/models/storage.dart
  5. 2
      packages/neon/neon/lib/src/utils/global_options.dart
  6. 4
      packages/neon/neon/lib/src/utils/push_utils.dart

2
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<AppImplementation> _allAppImplementations;
final _keyLastUsedAccount = 'last-used-account';

2
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));

2
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<PushNotification>();

2
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;

2
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 = <String, String Function(BuildContext)>{

4
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<String, dynamic>;
@ -98,7 +98,7 @@ class PushUtils {
NotificationsNotification? notification;
AndroidBitmap<Object>? largeIconBitmap;
try {
accounts = loadAccounts(AppStorage('accounts'));
accounts = loadAccounts(const AppStorage('accounts'));
account = accounts.tryFind(instance);
if (account != null) {
notification =

Loading…
Cancel
Save