mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-27 19:19: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
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { settingsSaveHelperSimpleFunction, defautOptionsAfterRender, trim, boolToAjax } from 'Common/Utils';
|
||||
import { settingsSaveHelperSimpleFunction, defautOptionsAfterRender, trim } from 'Common/Utils';
|
||||
|
||||
import { SaveSettingsStep, StorageResultType, Magics } from 'Common/Enums';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
|
@ -151,13 +151,13 @@ class ContactsAdminSettings {
|
|||
|
||||
this.enableContacts.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'ContactsEnable': boolToAjax(value)
|
||||
'ContactsEnable': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.contactsSync.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'ContactsSync': boolToAjax(value)
|
||||
'ContactsSync': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import ko from 'ko';
|
|||
import {
|
||||
trim,
|
||||
pInt,
|
||||
boolToAjax,
|
||||
settingsSaveHelperSimpleFunction,
|
||||
changeTheme,
|
||||
convertThemeName,
|
||||
|
|
@ -116,49 +115,49 @@ class GeneralAdminSettings {
|
|||
|
||||
this.capaAdditionalAccounts.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaAdditionalAccounts': boolToAjax(value)
|
||||
'CapaAdditionalAccounts': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.capaIdentities.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaIdentities': boolToAjax(value)
|
||||
'CapaIdentities': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.capaTemplates.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaTemplates': boolToAjax(value)
|
||||
'CapaTemplates': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.capaAttachmentThumbnails.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaAttachmentThumbnails': boolToAjax(value)
|
||||
'CapaAttachmentThumbnails': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.capaThemes.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaThemes': boolToAjax(value)
|
||||
'CapaThemes': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.capaUserBackground.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaUserBackground': boolToAjax(value)
|
||||
'CapaUserBackground': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.allowLanguagesOnSettings.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'AllowLanguagesOnSettings': boolToAjax(value)
|
||||
'AllowLanguagesOnSettings': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.newMoveToFolder.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'NewMoveToFolder': boolToAjax(value)
|
||||
'NewMoveToFolder': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
}, Magics.Time50ms);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { settingsSaveHelperSimpleFunction, boolToAjax, trim } from 'Common/Utils';
|
||||
import { settingsSaveHelperSimpleFunction, trim } from 'Common/Utils';
|
||||
import { settingsGet } from 'Storage/Settings';
|
||||
|
||||
import AppStore from 'Stores/Admin/App';
|
||||
|
|
@ -24,19 +24,19 @@ class LoginAdminSettings {
|
|||
|
||||
this.determineUserLanguage.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'DetermineUserLanguage': boolToAjax(value)
|
||||
'DetermineUserLanguage': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.determineUserDomain.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'DetermineUserDomain': boolToAjax(value)
|
||||
'DetermineUserDomain': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.allowLanguagesOnLogin.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'AllowLanguagesOnLogin': boolToAjax(value)
|
||||
'AllowLanguagesOnLogin': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import ko from 'ko';
|
|||
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
import { boolToAjax } from 'Common/Utils';
|
||||
|
||||
import { settingsGet } from 'Storage/Settings';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
|
@ -59,7 +58,7 @@ class PluginsAdminSettings {
|
|||
|
||||
this.enabledPlugins.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'EnabledPlugins': boolToAjax(value)
|
||||
'EnabledPlugins': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { trim, boolToAjax } from 'Common/Utils';
|
||||
import { trim } from 'Common/Utils';
|
||||
import { StorageResultType, Magics } from 'Common/Enums';
|
||||
|
||||
import { settingsGet } from 'Storage/Settings';
|
||||
|
|
@ -126,37 +126,37 @@ class SecurityAdminSettings {
|
|||
onBuild() {
|
||||
this.capaOpenPGP.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaOpenPGP': boolToAjax(value)
|
||||
'CapaOpenPGP': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.capaTwoFactorAuth.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaTwoFactorAuth': boolToAjax(value)
|
||||
'CapaTwoFactorAuth': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.capaTwoFactorAuthForce.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaTwoFactorAuthForce': boolToAjax(value)
|
||||
'CapaTwoFactorAuthForce': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.useLocalProxyForExternalImages.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'UseLocalProxyForExternalImages': boolToAjax(value)
|
||||
'UseLocalProxyForExternalImages': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.verifySslCertificate.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'VerifySslCertificate': boolToAjax(value)
|
||||
'VerifySslCertificate': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.allowSelfSigned.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'AllowSelfSigned': boolToAjax(value)
|
||||
'AllowSelfSigned': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import window from 'window';
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import { Capa, StorageResultType } from 'Common/Enums';
|
||||
|
|
@ -69,7 +68,7 @@ class AccountsUserSettings {
|
|||
setHash(root(), true);
|
||||
routeOff();
|
||||
|
||||
_.defer(() => window.location.reload());
|
||||
setTimeout(() => window.location.reload(), 1);
|
||||
} else {
|
||||
getApp().accountsAndIdentities();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { Magics } from 'Common/Enums';
|
||||
import { boolToAjax } from 'Common/Utils';
|
||||
|
||||
import AppStore from 'Stores/User/App';
|
||||
import ContactStore from 'Stores/User/Contact';
|
||||
|
|
@ -32,7 +31,7 @@ class ContactsUserSettings {
|
|||
onBuild() {
|
||||
this.contactsAutosave.subscribe((value) => {
|
||||
Remote.saveSettings(null, {
|
||||
'ContactsAutosave': boolToAjax(value)
|
||||
'ContactsAutosave': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { windowResizeCallback, isArray, trim, delegateRunOnDestroy } from 'Common/Utils';
|
||||
import { windowResizeCallback, trim, delegateRunOnDestroy } from 'Common/Utils';
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ class FiltersUserSettings {
|
|||
this.filters.loading(false);
|
||||
this.serverError(false);
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result && isArray(data.Result.Filters)) {
|
||||
if (StorageResultType.Success === result && data && data.Result && Array.isArray(data.Result.Filters)) {
|
||||
this.inited(true);
|
||||
this.serverError(false);
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ class FiltersUserSettings {
|
|||
this.modules(data.Result.Modules ? data.Result.Modules : {});
|
||||
|
||||
this.filterRaw(data.Result.Raw || '');
|
||||
this.filterRaw.capa(isArray(data.Result.Capa) ? data.Result.Capa.join(' ') : '');
|
||||
this.filterRaw.capa(Array.isArray(data.Result.Capa) ? data.Result.Capa.join(' ') : '');
|
||||
this.filterRaw.active(!!data.Result.RawIsActive);
|
||||
this.filterRaw.allow(!!data.Result.RawIsAllow);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { ClientSideKeyName, Notification, Magics } from 'Common/Enums';
|
||||
import { trim, noop } from 'Common/Utils';
|
||||
import { trim } from 'Common/Utils';
|
||||
import { getNotification, i18n } from 'Common/Translator';
|
||||
|
||||
import { removeFolderFromCacheList } from 'Common/Cache';
|
||||
|
|
@ -130,23 +130,23 @@ class FoldersUserSettings {
|
|||
|
||||
subscribeFolder(folder) {
|
||||
Local.set(ClientSideKeyName.FoldersLashHash, '');
|
||||
Remote.folderSetSubscribe(noop, folder.fullNameRaw, true);
|
||||
Remote.folderSetSubscribe(()=>{}, folder.fullNameRaw, true);
|
||||
folder.subScribed(true);
|
||||
}
|
||||
|
||||
unSubscribeFolder(folder) {
|
||||
Local.set(ClientSideKeyName.FoldersLashHash, '');
|
||||
Remote.folderSetSubscribe(noop, folder.fullNameRaw, false);
|
||||
Remote.folderSetSubscribe(()=>{}, folder.fullNameRaw, false);
|
||||
folder.subScribed(false);
|
||||
}
|
||||
|
||||
checkableTrueFolder(folder) {
|
||||
Remote.folderSetCheckable(noop, folder.fullNameRaw, true);
|
||||
Remote.folderSetCheckable(()=>{}, folder.fullNameRaw, true);
|
||||
folder.checkable(true);
|
||||
}
|
||||
|
||||
checkableFalseFolder(folder) {
|
||||
Remote.folderSetCheckable(noop, folder.fullNameRaw, false);
|
||||
Remote.folderSetCheckable(()=>{}, folder.fullNameRaw, false);
|
||||
folder.checkable(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { MESSAGES_PER_PAGE_VALUES } from 'Common/Consts';
|
|||
|
||||
import { SaveSettingsStep, Magics, EditorDefaultType, Layout } from 'Common/Enums';
|
||||
|
||||
import { settingsSaveHelperSimpleFunction, convertLangName, isArray, timeOutAction, boolToAjax } from 'Common/Utils';
|
||||
import { settingsSaveHelperSimpleFunction, convertLangName, timeOutAction } from 'Common/Utils';
|
||||
|
||||
import { i18n, trigger as translatorTrigger, reload as translatorReload } from 'Common/Translator';
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ class GeneralUserSettings {
|
|||
|
||||
this.identityMain = ko.computed(() => {
|
||||
const list = this.identities();
|
||||
return isArray(list) ? list.find(item => item && !item.id()) : null;
|
||||
return Array.isArray(list) ? list.find(item => item && !item.id()) : null;
|
||||
});
|
||||
|
||||
this.identityMainDesc = ko.computed(() => {
|
||||
|
|
@ -117,16 +117,16 @@ class GeneralUserSettings {
|
|||
|
||||
this.editorDefaultType.subscribe(Remote.saveSettingsHelper('EditorDefaultType', null, f0));
|
||||
this.messagesPerPage.subscribe(Remote.saveSettingsHelper('MPP', null, f1));
|
||||
this.showImages.subscribe(Remote.saveSettingsHelper('ShowImages', boolToAjax));
|
||||
this.showImages.subscribe(Remote.saveSettingsHelper('ShowImages', v=>v?'1':'0'));
|
||||
|
||||
this.useCheckboxesInList.subscribe(Remote.saveSettingsHelper('UseCheckboxesInList', boolToAjax));
|
||||
this.useCheckboxesInList.subscribe(Remote.saveSettingsHelper('UseCheckboxesInList', v=>v?'1':'0'));
|
||||
|
||||
this.enableDesktopNotification.subscribe((value) => {
|
||||
timeOutAction(
|
||||
'SaveDesktopNotifications',
|
||||
() => {
|
||||
Remote.saveSettings(null, {
|
||||
'DesktopNotifications': boolToAjax(value)
|
||||
'DesktopNotifications': value ? '1' : '0'
|
||||
});
|
||||
},
|
||||
Magics.Time3s
|
||||
|
|
@ -138,7 +138,7 @@ class GeneralUserSettings {
|
|||
'SaveSoundNotification',
|
||||
() => {
|
||||
Remote.saveSettings(null, {
|
||||
'SoundNotification': boolToAjax(value)
|
||||
'SoundNotification': value ? '1' : '0'
|
||||
});
|
||||
},
|
||||
Magics.Time3s
|
||||
|
|
@ -150,7 +150,7 @@ class GeneralUserSettings {
|
|||
'SaveReplySameFolder',
|
||||
() => {
|
||||
Remote.saveSettings(null, {
|
||||
'ReplySameFolder': boolToAjax(value)
|
||||
'ReplySameFolder': value ? '1' : '0'
|
||||
});
|
||||
},
|
||||
Magics.Time3s
|
||||
|
|
@ -160,7 +160,7 @@ class GeneralUserSettings {
|
|||
this.useThreads.subscribe((value) => {
|
||||
MessageStore.messageList([]);
|
||||
Remote.saveSettings(null, {
|
||||
'UseThreads': boolToAjax(value)
|
||||
'UseThreads': value ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { delegateRunOnDestroy, boolToAjax } from 'Common/Utils';
|
||||
import { delegateRunOnDestroy } from 'Common/Utils';
|
||||
import { Magics } from 'Common/Enums';
|
||||
import { bIsHttps } from 'Common/Globals';
|
||||
|
||||
import PgpStore from 'Stores/User/Pgp';
|
||||
import SettingsStore from 'Stores/User/Settings';
|
||||
|
|
@ -22,8 +21,6 @@ class OpenPgpUserSettings {
|
|||
this.openPgpKeyForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
|
||||
this.allowDraftAutosave = SettingsStore.allowDraftAutosave;
|
||||
|
||||
this.isHttps = bIsHttps;
|
||||
}
|
||||
|
||||
addOpenPgpKey() {
|
||||
|
|
@ -66,7 +63,7 @@ class OpenPgpUserSettings {
|
|||
|
||||
onBuild() {
|
||||
setTimeout(() => {
|
||||
this.allowDraftAutosave.subscribe(Remote.saveSettingsHelper('AllowDraftAutosave', boolToAjax));
|
||||
this.allowDraftAutosave.subscribe(Remote.saveSettingsHelper('AllowDraftAutosave', v=>v?'1':'0'));
|
||||
}, Magics.Time50ms);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue