Preparations for #1689

This commit is contained in:
the-djmaze 2024-08-06 12:19:17 +02:00
parent d2f3aa1c10
commit 166b790a3e
4 changed files with 18 additions and 11 deletions

View file

@ -1,6 +1,9 @@
import { AbstractModel } from 'Knoin/AbstractModel';
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { showScreenPopup } from 'Knoin/Knoin';
import { IdentityPopupView } from 'View/Popup/Identity';
export class IdentityModel extends AbstractModel {
/**
* @param {string} id
@ -47,4 +50,8 @@ export class IdentityModel extends AbstractModel {
label = this.label();
return (name ? `${name} ` : '') + `<${email}>` + (label ? ` (${label})` : '');
}
edit() {
showScreenPopup(IdentityPopupView, [this]);
}
}

View file

@ -48,7 +48,7 @@ export class UserSettingsAccounts /*extends AbstractViewSettings*/ {
}
editIdentity(identity) {
showScreenPopup(IdentityPopupView, [identity]);
identity.edit();
}
/**

View file

@ -6,7 +6,6 @@ import { LayoutSideView, LayoutBottomView } from 'Common/EnumsUser';
import { setRefreshFoldersInterval } from 'Common/Folders';
import { Settings, SettingsGet } from 'Common/Globals';
import { WYSIWYGS } from 'Common/HtmlEditor';
import { isArray } from 'Common/Utils';
import { addSubscribablesTo, addComputablesTo } from 'External/ko';
import { i18n, translateTrigger, translatorReload, convertLangName } from 'Common/Translator';
@ -23,7 +22,6 @@ import { MessagelistUserStore } from 'Stores/User/Messagelist';
import Remote from 'Remote/User/Fetch';
import { IdentityPopupView } from 'View/Popup/Identity';
import { LanguagesPopupView } from 'View/Popup/Languages';
export class UserSettingsGeneral extends AbstractViewSettings {
@ -75,13 +73,8 @@ export class UserSettingsGeneral extends AbstractViewSettings {
addComputablesTo(this, {
languageFullName: () => convertLangName(this.language()),
identityMain: () => {
const list = this.identities();
return isArray(list) ? list.find(item => item && !item.id()) : null;
},
identityMainDesc: () => {
const identity = this.identityMain();
const identity = IdentityUserStore.main();
return identity ? identity.formattedName() : '---';
},
@ -168,8 +161,7 @@ export class UserSettingsGeneral extends AbstractViewSettings {
}
editMainIdentity() {
const identity = this.identityMain();
identity && showScreenPopup(IdentityPopupView, [identity]);
IdentityUserStore.main()?.edit?.();
}
testSoundNotification() {

View file

@ -1,5 +1,13 @@
import { koArrayWithDestroy } from 'External/ko';
import { koComputable } from 'External/ko';
import { isArray } from 'Common/Utils';
export const IdentityUserStore = koArrayWithDestroy();
IdentityUserStore.loading = ko.observable(false).extend({ debounce: 100 });
/** Returns main (login) identity */
IdentityUserStore.main = koComputable(() => {
const list = IdentityUserStore();
return isArray(list) ? list.find(item => item && !item.id()) : null;
});