mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Code refactoring (es5 -> es2015)
This commit is contained in:
parent
fb2e492ce8
commit
38a1041a73
42 changed files with 3081 additions and 3690 deletions
|
|
@ -1,100 +1,95 @@
|
|||
|
||||
import {isNonEmptyArray, isUnd} from 'Common/Utils';
|
||||
import EmailModel from 'Model/Email';
|
||||
import {EmailModel} from 'Model/Email';
|
||||
|
||||
class MessageHelper
|
||||
{
|
||||
/**
|
||||
* @param {Array.<EmailModel>} emails
|
||||
* @param {boolean=} friendlyView = false
|
||||
* @param {boolean=} wrapWithLink = false
|
||||
* @returns {string}
|
||||
*/
|
||||
emailArrayToString(emails, friendlyView = false, wrapWithLink = false) {
|
||||
/**
|
||||
* @param {Array.<EmailModel>} emails
|
||||
* @param {boolean=} friendlyView = false
|
||||
* @param {boolean=} wrapWithLink = false
|
||||
* @returns {string}
|
||||
*/
|
||||
export function emailArrayToString(emails, friendlyView = false, wrapWithLink = false) {
|
||||
|
||||
let index = 0, len = 0;
|
||||
const result = [];
|
||||
let index = 0, len = 0;
|
||||
const result = [];
|
||||
|
||||
if (isNonEmptyArray(emails))
|
||||
if (isNonEmptyArray(emails))
|
||||
{
|
||||
for (len = emails.length; index < len; index++)
|
||||
{
|
||||
for (len = emails.length; index < len; index++)
|
||||
{
|
||||
result.push(emails[index].toLine(friendlyView, wrapWithLink));
|
||||
}
|
||||
result.push(emails[index].toLine(friendlyView, wrapWithLink));
|
||||
}
|
||||
|
||||
return result.join(', ');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array.<EmailModel>} emails
|
||||
* @returns {string}
|
||||
*/
|
||||
emailArrayToStringClear(emails) {
|
||||
return result.join(', ');
|
||||
}
|
||||
|
||||
let index = 0, len = 0;
|
||||
const result = [];
|
||||
/**
|
||||
* @param {Array.<EmailModel>} emails
|
||||
* @returns {string}
|
||||
*/
|
||||
export function emailArrayToStringClear(emails) {
|
||||
|
||||
if (isNonEmptyArray(emails))
|
||||
let index = 0, len = 0;
|
||||
const result = [];
|
||||
|
||||
if (isNonEmptyArray(emails))
|
||||
{
|
||||
for (len = emails.length; index < len; index++)
|
||||
{
|
||||
for (len = emails.length; index < len; index++)
|
||||
if (emails[index] && emails[index].email && '' !== emails[index].name)
|
||||
{
|
||||
if (emails[index] && emails[index].email && '' !== emails[index].name)
|
||||
{
|
||||
result.push(emails[index].email);
|
||||
}
|
||||
result.push(emails[index].email);
|
||||
}
|
||||
}
|
||||
|
||||
return result.join(', ');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Array} json
|
||||
* @returns {Array.<EmailModel>}
|
||||
*/
|
||||
emailArrayFromJson(json) {
|
||||
return result.join(', ');
|
||||
}
|
||||
|
||||
let index = 0, len = 0, email = null;
|
||||
const result = [];
|
||||
/**
|
||||
* @param {?Array} json
|
||||
* @returns {Array.<EmailModel>}
|
||||
*/
|
||||
export function emailArrayFromJson(json) {
|
||||
|
||||
if (isNonEmptyArray(json))
|
||||
let index = 0, len = 0, email = null;
|
||||
const result = [];
|
||||
|
||||
if (isNonEmptyArray(json))
|
||||
{
|
||||
for (index = 0, len = json.length; index < len; index++)
|
||||
{
|
||||
for (index = 0, len = json.length; index < len; index++)
|
||||
email = EmailModel.newInstanceFromJson(json[index]);
|
||||
if (email)
|
||||
{
|
||||
email = EmailModel.newInstanceFromJson(json[index]);
|
||||
if (email)
|
||||
{
|
||||
result.push(email);
|
||||
}
|
||||
result.push(email);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array.<EmailModel>} inputEmails
|
||||
* @param {Object} unic
|
||||
* @param {Array} localEmails
|
||||
*/
|
||||
replyHelper(inputEmails, unic, localEmails) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (inputEmails && 0 < inputEmails.length)
|
||||
/**
|
||||
* @param {Array.<EmailModel>} inputEmails
|
||||
* @param {Object} unic
|
||||
* @param {Array} localEmails
|
||||
*/
|
||||
export function replyHelper(inputEmails, unic, localEmails) {
|
||||
|
||||
if (inputEmails && 0 < inputEmails.length)
|
||||
{
|
||||
let index = 0;
|
||||
const len = inputEmails.length;
|
||||
|
||||
for (; index < len; index++)
|
||||
{
|
||||
let index = 0;
|
||||
const len = inputEmails.length;
|
||||
|
||||
for (; index < len; index++)
|
||||
if (isUnd(unic[inputEmails[index].email]))
|
||||
{
|
||||
if (isUnd(unic[inputEmails[index].email]))
|
||||
{
|
||||
unic[inputEmails[index].email] = true;
|
||||
localEmails.push(inputEmails[index]);
|
||||
}
|
||||
unic[inputEmails[index].email] = true;
|
||||
localEmails.push(inputEmails[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default new MessageHelper();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue