mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-10 17:13:38 +08:00
Improved EmailModel handling
This commit is contained in:
parent
57dc1d29b3
commit
e8c93a1d0c
2 changed files with 6 additions and 15 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue