Centralize loading of accounts and identities

This commit is contained in:
the-djmaze 2024-02-11 16:40:35 +01:00
parent 7c1f70c51e
commit ea55eb13e5
6 changed files with 42 additions and 38 deletions

View file

@ -1,8 +1,8 @@
import 'External/User/ko';
import { SMAudio } from 'Common/Audio';
import { isArray, pInt } from 'Common/Utils';
import { mailToHelper, setLayoutResizer, dropdownsDetectVisibility } from 'Common/UtilsUser';
import { pInt } from 'Common/Utils';
import { mailToHelper, setLayoutResizer, dropdownsDetectVisibility, loadAccountsAndIdentities } from 'Common/UtilsUser';
import {
FolderType,
@ -33,7 +33,6 @@ import { SettingsUserStore } from 'Stores/User/Settings';
import { NotificationUserStore } from 'Stores/User/Notification';
import { AccountUserStore } from 'Stores/User/Account';
import { ContactUserStore } from 'Stores/User/Contact';
import { IdentityUserStore } from 'Stores/User/Identity';
import { FolderUserStore } from 'Stores/User/Folder';
import { PgpUserStore } from 'Stores/User/Pgp';
import { MessagelistUserStore } from 'Stores/User/Messagelist';
@ -43,9 +42,6 @@ import { MessageUserStore } from 'Stores/User/Message';
import Remote from 'Remote/User/Fetch';
import { AccountModel } from 'Model/Account';
import { IdentityModel } from 'Model/Identity';
import { LoginUserScreen } from 'Screen/User/Login';
import { MailBoxUserScreen } from 'Screen/User/MailBox';
import { SettingsUserScreen } from 'Screen/User/Settings';
@ -139,31 +135,6 @@ export class AppUser extends AbstractApp {
}
}
accountsAndIdentities() {
AccountUserStore.loading(true);
IdentityUserStore.loading(true);
Remote.request('AccountsAndIdentities', (iError, oData) => {
AccountUserStore.loading(false);
IdentityUserStore.loading(false);
if (!iError) {
let items = oData.Result.Accounts;
AccountUserStore(isArray(items)
? items.map(oValue => new AccountModel(oValue.email, oValue.name))
: []
);
AccountUserStore.unshift(new AccountModel(SettingsGet('mainEmail'), '', false));
items = oData.Result.Identities;
IdentityUserStore(isArray(items)
? items.map(identityData => IdentityModel.reviveFromJson(identityData))
: []
);
}
});
}
/**
* @param {string} folder
* @param {Array=} list = []
@ -216,9 +187,7 @@ export class AppUser extends AbstractApp {
setRefreshFoldersInterval(pInt(SettingsGet('CheckMailInterval')));
ContactUserStore.init();
this.accountsAndIdentities();
loadAccountsAndIdentities();
setTimeout(() => {
const cF = FolderUserStore.currentFolderFullName();
@ -267,7 +236,6 @@ export class AppUser extends AbstractApp {
console.error(e);
}
});
} else {
startScreens([LoginUserScreen]);
}