mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 13:09:21 +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
|
|
@ -4,7 +4,7 @@ import { settingsGet } from 'Storage/Settings';
|
|||
|
||||
import { FolderType } from 'Common/Enums';
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
import { isArray, folderListOptionsBuilder } from 'Common/Utils';
|
||||
import { folderListOptionsBuilder } from 'Common/Utils';
|
||||
import { getFolderInboxName, getFolderFromCacheList } from 'Common/Cache';
|
||||
|
||||
import { momentNowUnix } from 'Common/Momentor';
|
||||
|
|
@ -72,7 +72,7 @@ class FolderUserStore {
|
|||
trashFolder = this.trashFolder(),
|
||||
archiveFolder = this.archiveFolder();
|
||||
|
||||
if (isArray(folders) && folders.length) {
|
||||
if (Array.isArray(folders) && folders.length) {
|
||||
if (sentFolder && UNUSED_OPTION_VALUE !== sentFolder) {
|
||||
list.push(sentFolder);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import window from 'window';
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
import $ from '$';
|
||||
|
||||
|
|
@ -8,7 +7,6 @@ import { Magics, Layout, Focused, MessageSetAction, StorageResultType, Notificat
|
|||
import {
|
||||
trim,
|
||||
isNormal,
|
||||
isArray,
|
||||
pInt,
|
||||
pString,
|
||||
plainToHtml,
|
||||
|
|
@ -102,7 +100,16 @@ class MessageUserStore {
|
|||
|
||||
this.onMessageResponse = this.onMessageResponse.bind(this);
|
||||
|
||||
this.purgeMessageBodyCacheThrottle = _.throttle(this.purgeMessageBodyCache, Magics.Time30s);
|
||||
// throttle
|
||||
var t, o = this;
|
||||
this.purgeMessageBodyCacheThrottle = ()=>{
|
||||
if (!t) {
|
||||
t = setTimeout(()=>{
|
||||
o.purgeMessageBodyCache();
|
||||
t = 0;
|
||||
}, Magics.Time30s);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
computers() {
|
||||
|
|
@ -184,14 +191,17 @@ class MessageUserStore {
|
|||
this.messageListCompleteLoadingThrottleForAnimation(value);
|
||||
});
|
||||
|
||||
var d;
|
||||
this.messageList.subscribe(
|
||||
_.debounce((list) => {
|
||||
list.forEach(item => {
|
||||
(list)=>{
|
||||
// debounce
|
||||
d && clearTimeout(d);
|
||||
d = setTimeout(()=>list.forEach(item => {
|
||||
if (item && item.newForAnimation()) {
|
||||
item.newForAnimation(false);
|
||||
}
|
||||
});
|
||||
}, Magics.Time500ms)
|
||||
}), Magics.Time500ms);
|
||||
}
|
||||
);
|
||||
|
||||
this.message.subscribe((message) => {
|
||||
|
|
@ -249,7 +259,7 @@ class MessageUserStore {
|
|||
|
||||
initUidNextAndNewMessages(folder, uidNext, newMessages) {
|
||||
if (getFolderInboxName() === folder && isNormal(uidNext) && uidNext) {
|
||||
if (isArray(newMessages) && newMessages.length) {
|
||||
if (Array.isArray(newMessages) && newMessages.length) {
|
||||
newMessages.forEach(item => {
|
||||
addNewMessageCache(folder, item.Uid);
|
||||
});
|
||||
|
|
@ -717,7 +727,7 @@ class MessageUserStore {
|
|||
data.Result &&
|
||||
'Collection/MessageCollection' === data.Result['@Object'] &&
|
||||
data.Result['@Collection'] &&
|
||||
isArray(data.Result['@Collection'])
|
||||
Array.isArray(data.Result['@Collection'])
|
||||
) {
|
||||
let newCount = 0,
|
||||
unreadCountChange = false;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
|
||||
import { i18n } from 'Common/Translator';
|
||||
import { log, isArray, isNonEmptyArray, pString, isUnd, trim } from 'Common/Utils';
|
||||
import { log, isNonEmptyArray, pString, trim } from 'Common/Utils';
|
||||
|
||||
import AccountStore from 'Stores/User/Account';
|
||||
|
||||
|
|
@ -56,7 +55,7 @@ class PgpUserStore {
|
|||
}
|
||||
|
||||
findPrivateKeysByEncryptionKeyIds(encryptionKeyIds, recipients, returnWrapKeys) {
|
||||
let result = isArray(encryptionKeyIds)
|
||||
let result = Array.isArray(encryptionKeyIds)
|
||||
? encryptionKeyIds.map(id => {
|
||||
const key = id && id.toHex ? this.findPrivateKeyByHex(id.toHex()) : null;
|
||||
return key ? (returnWrapKeys ? [key] : key.getNativeKeys()) : [null];
|
||||
|
|
@ -191,7 +190,7 @@ class PgpUserStore {
|
|||
if (publicKeys && publicKeys.length) {
|
||||
try {
|
||||
const result = message.verify(publicKeys),
|
||||
valid = (_.isArray(result) ? result : []).find(item => item && item.valid && item.keyid);
|
||||
valid = (Array.isArray(result) ? result : []).find(item => item && item.valid && item.keyid);
|
||||
|
||||
if (valid && valid.keyid && valid.keyid && valid.keyid.toHex) {
|
||||
fCallback(this.findPublicKeyByHex(valid.keyid.toHex()));
|
||||
|
|
@ -232,7 +231,7 @@ class PgpUserStore {
|
|||
.attr('title', title);
|
||||
}
|
||||
|
||||
if (!isUnd(text)) {
|
||||
if (undefined !== text) {
|
||||
dom.text(trim(text));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue