Message from, to, cc, bcc, replyTo and deliveredTo to the new EmailCollectionModel

This commit is contained in:
djmaze 2020-09-15 09:43:53 +02:00
parent b904eca98e
commit 062f8d078e
4 changed files with 100 additions and 128 deletions

View 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 };