mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
isArray to native Array.isArray
isUnd(*) to native undefined === *
isFunc to native typeof * === 'function'
isObject to native typeof * === 'object'
microtime() to native Date().getTime();
noop to native ()=>{}
noopFalse to native ()=>false
noopTrue to native ()=>true
boolToAjax to native *?'1':'0'
Underscore.js to native
This commit is contained in:
parent
fa39c7ecba
commit
ea48f5060b
72 changed files with 551 additions and 775 deletions
|
|
@ -2,7 +2,7 @@ import window from 'window';
|
|||
import ko from 'ko';
|
||||
|
||||
import { FileType } from 'Common/Enums';
|
||||
import { bAllowPdfPreview } from 'Common/Globals';
|
||||
import { bMobileDevice } from 'Common/Globals';
|
||||
import { trim, pInt, isNonEmptyArray, getFileExtension, friendlySize } from 'Common/Utils';
|
||||
import {
|
||||
attachmentDownload,
|
||||
|
|
@ -16,6 +16,8 @@ import { AbstractModel } from 'Knoin/AbstractModel';
|
|||
|
||||
import Audio from 'Common/Audio';
|
||||
|
||||
const bAllowPdfPreview = !bMobileDevice && undefined !== window.navigator.mimeTypes['application/pdf'];
|
||||
|
||||
/**
|
||||
* @param {string} sExt
|
||||
* @param {string} sMimeType
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import ko from 'ko';
|
||||
import { isUnd, pInt, friendlySize, mimeContentType, getFileExtension } from 'Common/Utils';
|
||||
import { pInt, friendlySize, mimeContentType, getFileExtension } from 'Common/Utils';
|
||||
|
||||
import { staticIconClass, staticFileType } from 'Model/Attachment';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
|
@ -75,8 +75,8 @@ class ComposeAttachmentModel extends AbstractModel {
|
|||
let bResult = false;
|
||||
if (json) {
|
||||
this.fileName(json.Name);
|
||||
this.size(isUnd(json.Size) ? 0 : pInt(json.Size));
|
||||
this.tempName(isUnd(json.TempName) ? '' : json.TempName);
|
||||
this.size(undefined === json.Size ? 0 : pInt(json.Size));
|
||||
this.tempName(undefined === json.TempName ? '' : json.TempName);
|
||||
this.isInline = false;
|
||||
|
||||
bResult = true;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ import { DATA_IMAGE_LAZY_PLACEHOLDER_PIC } from 'Common/Consts';
|
|||
|
||||
import {
|
||||
pInt,
|
||||
isArray,
|
||||
isUnd,
|
||||
trim,
|
||||
previewMessage,
|
||||
windowResize,
|
||||
|
|
@ -267,7 +265,7 @@ class MessageModel extends AbstractModel {
|
|||
this.unsubsribeLinks = isNonEmptyArray(json.UnsubsribeLinks) ? json.UnsubsribeLinks : [];
|
||||
|
||||
this.subject(json.Subject);
|
||||
if (isArray(json.SubjectParts)) {
|
||||
if (Array.isArray(json.SubjectParts)) {
|
||||
this.subjectPrefix(json.SubjectParts[0]);
|
||||
this.subjectSuffix(json.SubjectParts[1]);
|
||||
} else {
|
||||
|
|
@ -277,14 +275,14 @@ class MessageModel extends AbstractModel {
|
|||
|
||||
this.dateTimeStampInUTC(pInt(json.DateTimeStampInUTC));
|
||||
this.hasAttachments(!!json.HasAttachments);
|
||||
this.attachmentsSpecData(isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []);
|
||||
this.attachmentsSpecData(Array.isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []);
|
||||
|
||||
this.fromEmailString(emailArrayToString(this.from, true));
|
||||
this.fromClearEmailString(emailArrayToStringClear(this.from));
|
||||
this.toEmailsString(emailArrayToString(this.to, true));
|
||||
this.toClearEmailsString(emailArrayToStringClear(this.to));
|
||||
|
||||
this.threads(isArray(json.Threads) ? json.Threads : []);
|
||||
this.threads(Array.isArray(json.Threads) ? json.Threads : []);
|
||||
|
||||
this.initFlagsByJson(json);
|
||||
this.computeSenderEmail();
|
||||
|
|
@ -323,9 +321,9 @@ class MessageModel extends AbstractModel {
|
|||
}
|
||||
|
||||
this.hasAttachments(!!json.HasAttachments);
|
||||
this.attachmentsSpecData(isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []);
|
||||
this.attachmentsSpecData(Array.isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []);
|
||||
|
||||
this.foundedCIDs = isArray(json.FoundedCIDs) ? json.FoundedCIDs : [];
|
||||
this.foundedCIDs = Array.isArray(json.FoundedCIDs) ? json.FoundedCIDs : [];
|
||||
this.attachments(this.initAttachmentsFromJson(json.Attachments));
|
||||
|
||||
this.readReceipt(json.ReadReceipt || '');
|
||||
|
|
@ -545,7 +543,7 @@ class MessageModel extends AbstractModel {
|
|||
* @returns {string}
|
||||
*/
|
||||
fromAsSingleEmail() {
|
||||
return isArray(this.from) && this.from[0] ? this.from[0].email : '';
|
||||
return Array.isArray(this.from) && this.from[0] ? this.from[0].email : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -569,7 +567,7 @@ class MessageModel extends AbstractModel {
|
|||
*/
|
||||
replyEmails(excludeEmails, last = false) {
|
||||
const result = [],
|
||||
unic = isUnd(excludeEmails) ? {} : excludeEmails;
|
||||
unic = undefined === excludeEmails ? {} : excludeEmails;
|
||||
|
||||
replyHelper(this.replyTo, unic, result);
|
||||
if (!result.length) {
|
||||
|
|
@ -592,7 +590,7 @@ class MessageModel extends AbstractModel {
|
|||
let data = [];
|
||||
const toResult = [],
|
||||
ccResult = [],
|
||||
unic = isUnd(excludeEmails) ? {} : excludeEmails;
|
||||
unic = undefined === excludeEmails ? {} : excludeEmails;
|
||||
|
||||
replyHelper(this.replyTo, unic, toResult);
|
||||
if (!toResult.length) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue