Improved EmailModel handling

This commit is contained in:
the-djmaze 2023-02-12 18:28:30 +01:00
parent 57dc1d29b3
commit e8c93a1d0c
2 changed files with 6 additions and 15 deletions

View file

@ -266,7 +266,7 @@ export class EmailModel extends AbstractModel {
this.name = name;
this.dkimStatus = dkimStatus;
this.clearDuplicateName();
this.cleanup();
}
/**
@ -276,7 +276,7 @@ export class EmailModel extends AbstractModel {
*/
static reviveFromJson(json) {
const email = super.reviveFromJson(json);
email?.clearDuplicateName();
email?.cleanup();
return email;
}
@ -286,7 +286,6 @@ export class EmailModel extends AbstractModel {
clear() {
this.email = '';
this.name = '';
this.dkimStatus = 'none';
}
@ -297,18 +296,10 @@ export class EmailModel extends AbstractModel {
return this.name || this.email;
}
/**
* @param {boolean} withoutName = false
* @returns {string}
*/
hash(withoutName = false) {
return '#' + (withoutName ? '' : this.name) + '#' + (this.email || this.name) + '#';
}
/**
* @returns {void}
*/
clearDuplicateName() {
cleanup() {
if (this.name === this.email) {
this.name = '';
}
@ -385,7 +376,7 @@ export class EmailModel extends AbstractModel {
if (result.length) {
this.name = result[0].name || '';
this.email = result[0].address || '';
this.clearDuplicateName();
this.cleanup();
return true;
}
}

View file

@ -162,12 +162,12 @@ export class MailMessageList extends AbstractViewRight {
let list = [], current, sort = FolderUserStore.sortMode() || 'DATE';
if (sort.includes('FROM')) {
MessagelistUserStore.forEach(msg => {
let email = msg.from?.[0].email;
let email = msg.from[0].email;
if (!current || email != current.id) {
current = {
id: email,
label: msg.from[0].toLine(),
search: 'from=' + msg.from[0].email,
search: 'from=' + email,
messages: []
};
list.push(current);