|
|
@ -58,6 +58,8 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState |
|
|
|
this._globalOptions, |
|
|
|
this._globalOptions, |
|
|
|
this._allAppImplementations, |
|
|
|
this._allAppImplementations, |
|
|
|
) { |
|
|
|
) { |
|
|
|
|
|
|
|
const lastUsedStorage = SingleValueStorage('last-used-account'); |
|
|
|
|
|
|
|
|
|
|
|
accounts |
|
|
|
accounts |
|
|
|
..add(loadAccounts(_storage)) |
|
|
|
..add(loadAccounts(_storage)) |
|
|
|
..listen((final as) async { |
|
|
|
..listen((final as) async { |
|
|
@ -66,16 +68,16 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState |
|
|
|
}); |
|
|
|
}); |
|
|
|
activeAccount.listen((final aa) async { |
|
|
|
activeAccount.listen((final aa) async { |
|
|
|
if (aa != null) { |
|
|
|
if (aa != null) { |
|
|
|
await _storage.setString(_keyLastUsedAccount, aa.id); |
|
|
|
await lastUsedStorage.setString(aa.id); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
await _storage.remove(_keyLastUsedAccount); |
|
|
|
await lastUsedStorage.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
final as = accounts.value; |
|
|
|
final as = accounts.value; |
|
|
|
|
|
|
|
|
|
|
|
if (_globalOptions.rememberLastUsedAccount.value && _storage.containsKey(_keyLastUsedAccount)) { |
|
|
|
if (_globalOptions.rememberLastUsedAccount.value && lastUsedStorage.hasValue()) { |
|
|
|
final lastUsedAccountID = _storage.getString(_keyLastUsedAccount); |
|
|
|
final lastUsedAccountID = lastUsedStorage.getString(); |
|
|
|
if (lastUsedAccountID != null) { |
|
|
|
if (lastUsedAccountID != null) { |
|
|
|
final aa = as.tryFind(lastUsedAccountID); |
|
|
|
final aa = as.tryFind(lastUsedAccountID); |
|
|
|
if (aa != null) { |
|
|
|
if (aa != null) { |
|
|
@ -97,7 +99,6 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState |
|
|
|
late final AppStorage _storage = const AppStorage('accounts'); |
|
|
|
late final AppStorage _storage = const AppStorage('accounts'); |
|
|
|
final GlobalOptions _globalOptions; |
|
|
|
final GlobalOptions _globalOptions; |
|
|
|
final Iterable<AppImplementation> _allAppImplementations; |
|
|
|
final Iterable<AppImplementation> _allAppImplementations; |
|
|
|
final _keyLastUsedAccount = 'last-used-account'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final _accountsOptions = <String, AccountSpecificOptions>{}; |
|
|
|
final _accountsOptions = <String, AccountSpecificOptions>{}; |
|
|
|
final _appsBlocs = <String, AppsBloc>{}; |
|
|
|
final _appsBlocs = <String, AppsBloc>{}; |
|
|
|