mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Message from, to, cc, bcc, replyTo and deliveredTo to the new EmailCollectionModel
This commit is contained in:
parent
b904eca98e
commit
062f8d078e
4 changed files with 100 additions and 128 deletions
51
dev/Model/EmailCollection.js
Normal file
51
dev/Model/EmailCollection.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import { EmailModel } from 'Model/Email';
|
||||
|
||||
'use strict';
|
||||
|
||||
class EmailCollectionModel extends Array
|
||||
{
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Array} json
|
||||
* @returns {Array.<EmailModel>}
|
||||
*/
|
||||
static reviveFromJson(items) {
|
||||
let result = new EmailCollectionModel;
|
||||
if (Array.isArray(items)) {
|
||||
items.forEach(email => {
|
||||
email = EmailModel.newInstanceFromJson(email);
|
||||
email && result.push(email);
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean=} friendlyView = false
|
||||
* @param {boolean=} wrapWithLink = false
|
||||
* @returns {string}
|
||||
*/
|
||||
toString(friendlyView = false, wrapWithLink = false) {
|
||||
const result = [];
|
||||
this.forEach(email => result.push(email.toLine(friendlyView, wrapWithLink)));
|
||||
return result.join(', ');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
toStringClear() {
|
||||
const result = [];
|
||||
this.forEach(email => {
|
||||
if (email && email.email && email.name) {
|
||||
result.push(email.email);
|
||||
}
|
||||
});
|
||||
return result.join(', ');
|
||||
}
|
||||
}
|
||||
|
||||
export { EmailCollectionModel, EmailCollectionModel as default };
|
||||
Loading…
Add table
Add a link
Reference in a new issue