mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 11:39:21 +03:00
Small fixes
This commit is contained in:
parent
fcfd54215a
commit
aeec36de19
7 changed files with 123 additions and 129 deletions
112
dev/Helper/Message.jsx
Normal file
112
dev/Helper/Message.jsx
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
|
||||
import Utils from 'Common/Utils';
|
||||
import EmailModel from 'Model/Email';
|
||||
|
||||
class MessageHelper
|
||||
{
|
||||
constructor() {}
|
||||
|
||||
/**
|
||||
* @param {Array.<EmailModel>} emails
|
||||
* @param {boolean=} friendlyView = false
|
||||
* @param {boolean=} wrapWithLink = false
|
||||
* @return {string}
|
||||
*/
|
||||
emailArrayToString(emails, friendlyView = false, wrapWithLink = false) {
|
||||
|
||||
let
|
||||
result = [],
|
||||
index = 0,
|
||||
len = 0
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(emails))
|
||||
{
|
||||
for (index = 0, len = emails.length; index < len; index++)
|
||||
{
|
||||
result.push(emails[index].toLine(friendlyView, wrapWithLink));
|
||||
}
|
||||
}
|
||||
|
||||
return result.join(', ');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array.<EmailModel>} emails
|
||||
* @return {string}
|
||||
*/
|
||||
emailArrayToStringClear(emails) {
|
||||
|
||||
let
|
||||
result = [],
|
||||
index = 0,
|
||||
len = 0
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(emails))
|
||||
{
|
||||
for (index = 0, len = emails.length; index < len; index++)
|
||||
{
|
||||
if (emails[index] && emails[index].email && '' !== emails[index].name)
|
||||
{
|
||||
result.push(emails[index].email);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.join(', ');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Array} json
|
||||
* @return {Array.<EmailModel>}
|
||||
*/
|
||||
emailArrayFromJson(json) {
|
||||
|
||||
let
|
||||
index = 0,
|
||||
len = 0,
|
||||
email = null,
|
||||
result = []
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(json))
|
||||
{
|
||||
for (index = 0, len = json.length; index < len; index++)
|
||||
{
|
||||
email = EmailModel.newInstanceFromJson(json[index]);
|
||||
if (email)
|
||||
{
|
||||
result.push(email);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array.<EmailModel>} inputEmails
|
||||
* @param {Object} unic
|
||||
* @param {Array} localEmails
|
||||
*/
|
||||
replyHelper(inputEmails, unic, localEmails) {
|
||||
|
||||
if (inputEmails && 0 < inputEmails.length)
|
||||
{
|
||||
let index = 0;
|
||||
const len = inputEmails.length;
|
||||
|
||||
for (; index < len; index++)
|
||||
{
|
||||
if (Utils.isUnd(unic[inputEmails[index].email]))
|
||||
{
|
||||
unic[inputEmails[index].email] = true;
|
||||
localEmails.push(inputEmails[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default new MessageHelper();
|
||||
Loading…
Add table
Add a link
Reference in a new issue