Browse Source

Merge pull request #359 from provokateurin/fix/missing-active-account

neon: Fix missing active account
pull/364/head
Kate 2 years ago committed by GitHub
parent
commit
9af5b59ff9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      packages/neon/neon/lib/src/blocs/accounts.dart

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

@ -37,20 +37,30 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
});
final as = accounts.value;
if (_globalOptions.rememberLastUsedAccount.value && _storage.containsKey(_keyLastUsedAccount)) {
final lastUsedAccountID = _storage.getString(_keyLastUsedAccount);
activeAccount.add(lastUsedAccountID != null ? as.find(lastUsedAccountID) : null);
} else {
if (lastUsedAccountID != null) {
final aa = as.find(lastUsedAccountID);
if (aa != null) {
setActiveAccount(aa);
}
}
}
unawaited(
_globalOptions.initialAccount.stream.first.then((final lastAccount) {
final account = lastAccount != null ? as.find(lastAccount) : null;
if (activeAccount.valueOrNull == null) {
if (account != null) {
activeAccount.add(account);
setActiveAccount(account);
} else if (as.isNotEmpty) {
setActiveAccount(as.first);
}
}
}),
);
}
}
final RequestManager _requestManager;
final NeonPlatform _platform;

Loading…
Cancel
Save