mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 19:49:20 +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
|
|
@ -1,7 +1,7 @@
|
|||
import window from 'window';
|
||||
|
||||
import { ajax } from 'Common/Links';
|
||||
import { isUnd, isNormal, pString } from 'Common/Utils';
|
||||
import { isNormal, pString } from 'Common/Utils';
|
||||
import { DEFAULT_AJAX_TIMEOUT, TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT } from 'Common/Consts';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { data as GlobalsData } from 'Common/Globals';
|
||||
|
|
@ -39,7 +39,7 @@ class AbstractAjaxPromises extends AbstractBasicPromises {
|
|||
|
||||
ajaxRequest(action, isPost, timeOut, params, additionalGetString, fTrigger) {
|
||||
|
||||
additionalGetString = isUnd(additionalGetString) ? '' : pString(additionalGetString);
|
||||
additionalGetString = undefined === additionalGetString ? '' : pString(additionalGetString);
|
||||
|
||||
let init = {
|
||||
mode: 'same-origin',
|
||||
|
|
@ -155,7 +155,6 @@ class AbstractAjaxPromises extends AbstractBasicPromises {
|
|||
|
||||
return data;
|
||||
}).catch(err => {
|
||||
window.console.log('AbstractAjaxPromises ' + action + ' request failed:', err, Notification.getKeyByValue(err));
|
||||
if (err.name == 'AbortError') { // handle abort()
|
||||
return Promise.reject(Notification.AjaxAbort);
|
||||
}
|
||||
|
|
@ -164,7 +163,7 @@ window.console.log('AbstractAjaxPromises ' + action + ' request failed:', err, N
|
|||
}
|
||||
|
||||
getRequest(sAction, fTrigger, sAdditionalGetString, iTimeOut) {
|
||||
sAdditionalGetString = isUnd(sAdditionalGetString) ? '' : pString(sAdditionalGetString);
|
||||
sAdditionalGetString = undefined === sAdditionalGetString ? '' : pString(sAdditionalGetString);
|
||||
sAdditionalGetString = sAction + '/' + sAdditionalGetString;
|
||||
|
||||
return this.ajaxRequest(sAction, false, iTimeOut, null, sAdditionalGetString, fTrigger);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import window from 'window';
|
||||
import { isArray } from 'Common/Utils';
|
||||
|
||||
export class AbstractBasicPromises {
|
||||
oPromisesStack = {};
|
||||
|
|
@ -20,7 +19,7 @@ export class AbstractBasicPromises {
|
|||
setTrigger(trigger, value) {
|
||||
if (trigger) {
|
||||
value = !!value;
|
||||
(isArray(trigger) ? trigger : [trigger]).forEach((fTrigger) => {
|
||||
(Array.isArray(trigger) ? trigger : [trigger]).forEach((fTrigger) => {
|
||||
if (fTrigger) {
|
||||
fTrigger(value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
import { isArray, isNormal, pInt, isUnd, noop } from 'Common/Utils';
|
||||
import { isNormal, pInt } from 'Common/Utils';
|
||||
import { ClientSideKeyName, ServerFolderType } from 'Common/Enums';
|
||||
import * as Cache from 'Common/Cache';
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ class PromisesUserPopulator extends AbstractBasicPromises {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
isFolderExpanded(sFullNameHash, expandedFolders) {
|
||||
return expandedFolders && isArray(expandedFolders) && expandedFolders.includes(sFullNameHash);
|
||||
return expandedFolders && Array.isArray(expandedFolders) && expandedFolders.includes(sFullNameHash);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -84,7 +84,7 @@ class PromisesUserPopulator extends AbstractBasicPromises {
|
|||
oFolder.SubFolders &&
|
||||
'Collection/FolderCollection' === oFolder.SubFolders['@Object'] &&
|
||||
oFolder.SubFolders['@Collection'] &&
|
||||
isArray(oFolder.SubFolders['@Collection'])
|
||||
Array.isArray(oFolder.SubFolders['@Collection'])
|
||||
) {
|
||||
oCacheFolder.subFolders(
|
||||
this.folderResponseParseRec(sNamespace, oFolder.SubFolders['@Collection'], expandedFolders)
|
||||
|
|
@ -104,7 +104,7 @@ class PromisesUserPopulator extends AbstractBasicPromises {
|
|||
oData &&
|
||||
'Collection/FolderCollection' === oData['@Object'] &&
|
||||
oData['@Collection'] &&
|
||||
isArray(oData['@Collection'])
|
||||
Array.isArray(oData['@Collection'])
|
||||
) {
|
||||
const expandedFolders = Local.get(ClientSideKeyName.ExpandedFolders),
|
||||
cnt = pInt(oData.CountRec);
|
||||
|
|
@ -116,7 +116,7 @@ class PromisesUserPopulator extends AbstractBasicPromises {
|
|||
|
||||
FolderStore.folderList(
|
||||
this.folderResponseParseRec(
|
||||
isUnd(oData.Namespace) ? '' : oData.Namespace,
|
||||
undefined === oData.Namespace ? '' : oData.Namespace,
|
||||
oData['@Collection'],
|
||||
expandedFolders
|
||||
)
|
||||
|
|
@ -130,9 +130,9 @@ class PromisesUserPopulator extends AbstractBasicPromises {
|
|||
oData &&
|
||||
'Collection/FolderCollection' === oData['@Object'] &&
|
||||
oData['@Collection'] &&
|
||||
isArray(oData['@Collection'])
|
||||
Array.isArray(oData['@Collection'])
|
||||
) {
|
||||
if (!isUnd(oData.Namespace)) {
|
||||
if (undefined !== oData.Namespace) {
|
||||
FolderStore.namespace = oData.Namespace;
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ class PromisesUserPopulator extends AbstractBasicPromises {
|
|||
FolderStore.archiveFolder(this.normalizeFolder(Settings.settingsGet('ArchiveFolder')));
|
||||
|
||||
if (update) {
|
||||
Remote.saveSystemFolders(noop, {
|
||||
Remote.saveSystemFolders(()=>{}, {
|
||||
SentFolder: FolderStore.sentFolder(),
|
||||
DraftFolder: FolderStore.draftFolder(),
|
||||
SpamFolder: FolderStore.spamFolder(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue