added computed member for knowing if there are accounts

This commit is contained in:
shilangyu 2020-09-08 21:44:52 +02:00
parent 62beee4d5c
commit 9b3caf4927
1 changed files with 4 additions and 1 deletions

View File

@ -102,6 +102,9 @@ abstract class _AccountsStore with Store {
bool isAnonymousFor(String instanceUrl) =>
Computed(() => users[instanceUrl].isEmpty).value;
@computed
bool get hasNoAccount => users.values.every((e) => e.isEmpty);
/// adds a new account
/// if it's the first account ever the account is
/// set as default for the app
@ -129,7 +132,7 @@ abstract class _AccountsStore with Store {
// first account for this instance
if (users[instanceUrl].isEmpty) {
// first account ever
if (users.values.every((e) => e.isEmpty)) {
if (hasNoAccount) {
setDefaultAccount(instanceUrl, userData.name);
}