mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03: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.name = name;
|
||||||
this.dkimStatus = dkimStatus;
|
this.dkimStatus = dkimStatus;
|
||||||
|
|
||||||
this.clearDuplicateName();
|
this.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -276,7 +276,7 @@ export class EmailModel extends AbstractModel {
|
||||||
*/
|
*/
|
||||||
static reviveFromJson(json) {
|
static reviveFromJson(json) {
|
||||||
const email = super.reviveFromJson(json);
|
const email = super.reviveFromJson(json);
|
||||||
email?.clearDuplicateName();
|
email?.cleanup();
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -286,7 +286,6 @@ export class EmailModel extends AbstractModel {
|
||||||
clear() {
|
clear() {
|
||||||
this.email = '';
|
this.email = '';
|
||||||
this.name = '';
|
this.name = '';
|
||||||
|
|
||||||
this.dkimStatus = 'none';
|
this.dkimStatus = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,18 +296,10 @@ export class EmailModel extends AbstractModel {
|
||||||
return this.name || this.email;
|
return this.name || this.email;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean} withoutName = false
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
hash(withoutName = false) {
|
|
||||||
return '#' + (withoutName ? '' : this.name) + '#' + (this.email || this.name) + '#';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
clearDuplicateName() {
|
cleanup() {
|
||||||
if (this.name === this.email) {
|
if (this.name === this.email) {
|
||||||
this.name = '';
|
this.name = '';
|
||||||
}
|
}
|
||||||
|
|
@ -385,7 +376,7 @@ export class EmailModel extends AbstractModel {
|
||||||
if (result.length) {
|
if (result.length) {
|
||||||
this.name = result[0].name || '';
|
this.name = result[0].name || '';
|
||||||
this.email = result[0].address || '';
|
this.email = result[0].address || '';
|
||||||
this.clearDuplicateName();
|
this.cleanup();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,12 +162,12 @@ export class MailMessageList extends AbstractViewRight {
|
||||||
let list = [], current, sort = FolderUserStore.sortMode() || 'DATE';
|
let list = [], current, sort = FolderUserStore.sortMode() || 'DATE';
|
||||||
if (sort.includes('FROM')) {
|
if (sort.includes('FROM')) {
|
||||||
MessagelistUserStore.forEach(msg => {
|
MessagelistUserStore.forEach(msg => {
|
||||||
let email = msg.from?.[0].email;
|
let email = msg.from[0].email;
|
||||||
if (!current || email != current.id) {
|
if (!current || email != current.id) {
|
||||||
current = {
|
current = {
|
||||||
id: email,
|
id: email,
|
||||||
label: msg.from[0].toLine(),
|
label: msg.from[0].toLine(),
|
||||||
search: 'from=' + msg.from[0].email,
|
search: 'from=' + email,
|
||||||
messages: []
|
messages: []
|
||||||
};
|
};
|
||||||
list.push(current);
|
list.push(current);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue