mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 19:49:20 +03:00
Resolve #571 by allowing to give an account a name/label
This commit is contained in:
parent
2ee9d973e2
commit
decbbd8817
13 changed files with 168 additions and 122 deletions
|
|
@ -152,41 +152,29 @@ export class AppUser extends AbstractApp {
|
|||
IdentityUserStore.loading(false);
|
||||
|
||||
if (!iError) {
|
||||
const
|
||||
// counts = {},
|
||||
accounts = oData.Result.Accounts,
|
||||
mainEmail = SettingsGet('MainEmail');
|
||||
let items = oData.Result.Accounts;
|
||||
AccountUserStore(isArray(items)
|
||||
? items.map(oValue => new AccountModel(oValue.email, oValue.name))
|
||||
: []
|
||||
);
|
||||
AccountUserStore.unshift(new AccountModel(SettingsGet('MainEmail'), '', false));
|
||||
|
||||
if (isArray(accounts)) {
|
||||
// AccountUserStore.accounts.forEach(oAccount => counts[oAccount.email] = oAccount.count());
|
||||
|
||||
AccountUserStore.accounts(
|
||||
accounts.map(
|
||||
sValue => new AccountModel(sValue/*, counts[sValue]*/)
|
||||
)
|
||||
);
|
||||
// accounts.length &&
|
||||
AccountUserStore.accounts.unshift(new AccountModel(mainEmail/*, counts[mainEmail]*/, false));
|
||||
}
|
||||
|
||||
if (isArray(oData.Result.Identities)) {
|
||||
IdentityUserStore(
|
||||
oData.Result.Identities.map(identityData => {
|
||||
const identity = new IdentityModel(
|
||||
pString(identityData.Id),
|
||||
pString(identityData.Email)
|
||||
);
|
||||
|
||||
identity.name(pString(identityData.Name));
|
||||
identity.replyTo(pString(identityData.ReplyTo));
|
||||
identity.bcc(pString(identityData.Bcc));
|
||||
identity.signature(pString(identityData.Signature));
|
||||
identity.signatureInsertBefore(!!identityData.SignatureInsertBefore);
|
||||
|
||||
return identity;
|
||||
})
|
||||
);
|
||||
}
|
||||
items = oData.Result.Identities;
|
||||
IdentityUserStore(isArray(items)
|
||||
? items.map(identityData => {
|
||||
const identity = new IdentityModel(
|
||||
pString(identityData.Id),
|
||||
pString(identityData.Email)
|
||||
);
|
||||
identity.name(pString(identityData.Name));
|
||||
identity.replyTo(pString(identityData.ReplyTo));
|
||||
identity.bcc(pString(identityData.Bcc));
|
||||
identity.signature(pString(identityData.Signature));
|
||||
identity.signatureInsertBefore(!!identityData.SignatureInsertBefore);
|
||||
return identity;
|
||||
})
|
||||
: []
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@ export class AccountModel extends AbstractModel {
|
|||
* @param {boolean=} canBeDelete = true
|
||||
* @param {number=} count = 0
|
||||
*/
|
||||
constructor(email/*, count = 0*/, isAdditional = true) {
|
||||
constructor(email, name/*, count = 0*/, isAdditional = true) {
|
||||
super();
|
||||
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
|
||||
this.displayName = name ? name + ' <' + email + '>' : email;
|
||||
|
||||
addObservablesTo(this, {
|
||||
// count: count || 0,
|
||||
askDelete: false,
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ export class MailBoxUserScreen extends AbstractScreen {
|
|||
FolderUserStore.foldersInboxUnreadCount(e.detail);
|
||||
/* // Disabled in SystemDropDown.html
|
||||
const email = AccountUserStore.email();
|
||||
AccountUserStore.accounts.forEach(item =>
|
||||
AccountUserStore.forEach(item =>
|
||||
email === item?.email && item?.count(e.detail)
|
||||
);
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export class UserSettingsAccounts /*extends AbstractViewSettings*/ {
|
|||
this.allowAdditionalAccount = SettingsCapa('AdditionalAccounts');
|
||||
this.allowIdentities = SettingsCapa('Identities');
|
||||
|
||||
this.accounts = AccountUserStore.accounts;
|
||||
this.accounts = AccountUserStore;
|
||||
this.loading = AccountUserStore.loading;
|
||||
this.identities = IdentityUserStore;
|
||||
this.mainEmail = SettingsGet('MainEmail');
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import { addObservablesTo, koArrayWithDestroy } from 'External/ko';
|
||||
|
||||
export const AccountUserStore = {
|
||||
accounts: koArrayWithDestroy(),
|
||||
loading: ko.observable(false).extend({ debounce: 100 }),
|
||||
export const AccountUserStore = koArrayWithDestroy();
|
||||
|
||||
getEmailAddresses: () => AccountUserStore.accounts.map(item => item.email)
|
||||
};
|
||||
AccountUserStore.loading = ko.observable(false).extend({ debounce: 100 });
|
||||
|
||||
AccountUserStore.getEmailAddresses = () => AccountUserStore.map(item => item.email);
|
||||
|
||||
addObservablesTo(AccountUserStore, {
|
||||
email: '',
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export class AccountPopupView extends AbstractViewPopup {
|
|||
addObservablesTo(this, {
|
||||
isNew: true,
|
||||
|
||||
name: '',
|
||||
email: '',
|
||||
password: '',
|
||||
|
||||
|
|
@ -40,18 +41,17 @@ export class AccountPopupView extends AbstractViewPopup {
|
|||
}
|
||||
}
|
||||
|
||||
onShow(account) {
|
||||
if (account?.isAdditional()) {
|
||||
this.isNew(false);
|
||||
this.email(account.email);
|
||||
} else {
|
||||
this.isNew(true);
|
||||
this.email('');
|
||||
}
|
||||
onHide() {
|
||||
this.password('');
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
this.submitErrorAdditional('');
|
||||
}
|
||||
|
||||
onShow(account) {
|
||||
let edit = account?.isAdditional();
|
||||
this.isNew(!edit);
|
||||
this.name(edit ? account.name : '');
|
||||
this.email(edit ? account.email : '');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ export class SystemDropDownUserView extends AbstractViewRight {
|
|||
|
||||
this.accountEmail = AccountUserStore.email;
|
||||
|
||||
this.accounts = AccountUserStore.accounts;
|
||||
this.accounts = AccountUserStore;
|
||||
this.accountsLoading = AccountUserStore.loading;
|
||||
/*
|
||||
this.accountsUnreadCount = : koComputable(() => 0);
|
||||
this.accountsUnreadCount = : koComputable(() => AccountUserStore.accounts().reduce((result, item) => result + item.count(), 0));
|
||||
this.accountsUnreadCount = : koComputable(() => AccountUserStore().reduce((result, item) => result + item.count(), 0));
|
||||
*/
|
||||
|
||||
addObservablesTo(this, {
|
||||
|
|
@ -91,8 +91,10 @@ export class SystemDropDownUserView extends AbstractViewRight {
|
|||
return true;
|
||||
}
|
||||
|
||||
emailTitle() {
|
||||
return AccountUserStore.email();
|
||||
accountName() {
|
||||
let email = AccountUserStore.email(),
|
||||
account = AccountUserStore.find(account => account.email == email);
|
||||
return account?.name || email;
|
||||
}
|
||||
|
||||
settingsClick() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue