diff --git a/dev/App/Admin.js b/dev/App/Admin.js index 73e34a4ff..f1f1d2b27 100644 --- a/dev/App/Admin.js +++ b/dev/App/Admin.js @@ -2,6 +2,7 @@ import 'External/Admin/ko'; import ko from 'ko'; import { StorageResultType } from 'Common/Enums'; +import { Settings, SettingsGet } from 'Common/Globals'; import { AppAdminStore } from 'Stores/Admin/App'; import { CapaAdminStore } from 'Stores/Admin/Capa'; @@ -103,11 +104,11 @@ class AdminApp extends AbstractApp { this.hideLoading(); - if (!rl.settings.app('allowAdminPanel')) { + if (!Settings.app('allowAdminPanel')) { rl.route.root(); setTimeout(() => location.href = '/', 1); } else { - if (rl.settings.get('Auth')) { + if (SettingsGet('Auth')) { startScreens([SettingsAdminScreen]); } else { startScreens([LoginAdminScreen]); diff --git a/dev/App/User.js b/dev/App/User.js index a8d1830cc..c9dd5f98e 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -24,6 +24,7 @@ import { createElement, $htmlCL, Settings, + SettingsGet, leftPanelDisabled } from 'Common/Globals'; @@ -116,9 +117,9 @@ class AppUser extends AbstractApp { this.reload(); } - if (Settings.get('UserBackgroundHash')) { + if (SettingsGet('UserBackgroundHash')) { setTimeout(() => { - const img = userBackground(Settings.get('UserBackgroundHash')); + const img = userBackground(SettingsGet('UserBackgroundHash')); if (img) { $htmlCL.add('UserBackground'); doc.body.style.backgroundImage = "url("+img+")"; @@ -485,7 +486,7 @@ class AppUser extends AbstractApp { if (StorageResultType.Success === sResult && oData.Result) { const counts = {}, sAccountEmail = AccountStore.email(); - let parentEmail = Settings.get('ParentEmail') || sAccountEmail; + let parentEmail = SettingsGet('ParentEmail') || sAccountEmail; if (Array.isArray(oData.Result.Accounts)) { AccountStore.accounts.forEach(oAccount => @@ -887,7 +888,7 @@ class AppUser extends AbstractApp { } logout() { - Remote.logout(() => this.logoutReload(0 < (Settings.get('ParentEmail')||{length:0}).length)); + Remote.logout(() => this.logoutReload(0 < (SettingsGet('ParentEmail')||{length:0}).length)); } bootend() { @@ -906,18 +907,18 @@ class AppUser extends AbstractApp { AccountStore.populate(); ContactStore.populate(); - let contactsSyncInterval = pInt(Settings.get('ContactsSyncInterval')); + let contactsSyncInterval = pInt(SettingsGet('ContactsSyncInterval')); - const startupUrl = pString(Settings.get('StartupUrl')); + const startupUrl = pString(SettingsGet('StartupUrl')); progressJs.set(90); rl.setWindowTitle(); - if (Settings.get('Auth')) { + if (SettingsGet('Auth')) { if ( Settings.capa(Capa.TwoFactor) && Settings.capa(Capa.TwoFactorForce) && - Settings.get('RequireTwoFactor') + SettingsGet('RequireTwoFactor') ) { this.bootend(); showScreenPopup(TwoFactorConfigurationPopupView, [true]); @@ -1010,7 +1011,7 @@ class AppUser extends AbstractApp { // When auto-login is active if ( - Settings.get('AccountSignMe') && + !!SettingsGet('AccountSignMe') && navigator.registerProtocolHandler && Settings.capa(Capa.Composer) ) { @@ -1019,12 +1020,12 @@ class AppUser extends AbstractApp { navigator.registerProtocolHandler( 'mailto', location.protocol + '//' + location.host + location.pathname + '?mailto&to=%s', - (Settings.get('Title') || 'SnappyMail') + (SettingsGet('Title') || 'SnappyMail') ); } catch (e) {} // eslint-disable-line no-empty - if (Settings.get('MailToEmail')) { - mailToHelper(Settings.get('MailToEmail')); + if (SettingsGet('MailToEmail')) { + mailToHelper(SettingsGet('MailToEmail')); } }, 500); } diff --git a/dev/Common/Globals.js b/dev/Common/Globals.js index 936a052da..a4ec55ad1 100644 --- a/dev/Common/Globals.js +++ b/dev/Common/Globals.js @@ -8,6 +8,7 @@ export const $htmlCL = doc.documentElement.classList; export const elementById = id => doc.getElementById(id); export const Settings = rl.settings; +export const SettingsGet = rl.settings.get; export const dropdownVisibility = ko.observable(false).extend({ rateLimit: 0 }); diff --git a/dev/Common/Links.js b/dev/Common/Links.js index d2a197cb3..7ae30d4f6 100644 --- a/dev/Common/Links.js +++ b/dev/Common/Links.js @@ -1,5 +1,5 @@ import { pString, pInt } from 'Common/Utils'; -import { Settings } from 'Common/Globals'; +import { Settings, SettingsGet } from 'Common/Globals'; const ROOT = './', @@ -8,7 +8,7 @@ const VERSION = Settings.app('version'), VERSION_PREFIX = Settings.app('webVersionPath') || 'snappymail/v/' + VERSION + '/', - getHash = () => Settings.get('AuthAccountHash') || '0'; + getHash = () => SettingsGet('AuthAccountHash') || '0'; /** * @returns {string} diff --git a/dev/Common/Plugins.js b/dev/Common/Plugins.js index e49164fd4..370eaa446 100644 --- a/dev/Common/Plugins.js +++ b/dev/Common/Plugins.js @@ -1,4 +1,5 @@ import { settingsAddViewModel } from 'Screen/AbstractSettings'; +import { SettingsGet } from 'Common/Globals'; const USER_VIEW_MODELS_HOOKS = [], ADMIN_VIEW_MODELS_HOOKS = []; @@ -48,7 +49,7 @@ export function runSettingsViewModelHooks(admin) { * @returns {?} */ rl.pluginSettingsGet = (pluginSection, name) => { - let plugins = rl.settings.get('Plugins'); + let plugins = SettingsGet('Plugins'); plugins = plugins && null != plugins[pluginSection] ? plugins[pluginSection] : null; return plugins ? (null == plugins[name] ? null : plugins[name]) : null; }; diff --git a/dev/Common/UtilsUser.js b/dev/Common/UtilsUser.js index db3942b6d..b10a583f2 100644 --- a/dev/Common/UtilsUser.js +++ b/dev/Common/UtilsUser.js @@ -504,5 +504,5 @@ export function mailToHelper(mailToUrl) { export function showMessageComposer(params = []) { - rl.app.showScreenPopup(params); + rl.app.showMessageComposer(params); } diff --git a/dev/Model/FolderCollection.js b/dev/Model/FolderCollection.js index ebc58aa6a..52836d808 100644 --- a/dev/Model/FolderCollection.js +++ b/dev/Model/FolderCollection.js @@ -4,7 +4,7 @@ import { UNUSED_OPTION_VALUE } from 'Common/Consts'; import { pInt } from 'Common/Utils'; import { ClientSideKeyName, FolderType } from 'Common/EnumsUser'; import * as Cache from 'Common/Cache'; -import { Settings } from 'Common/Globals'; +import { Settings, SettingsGet } from 'Common/Globals'; import * as Local from 'Storage/Client'; @@ -119,12 +119,12 @@ export class FolderCollectionModel extends AbstractCollectionModel if ( this.SystemFolders && !('' + - Settings.get('SentFolder') + - Settings.get('DraftFolder') + - Settings.get('SpamFolder') + - Settings.get('TrashFolder') + - Settings.get('ArchiveFolder') + - Settings.get('NullFolder')) + SettingsGet('SentFolder') + + SettingsGet('DraftFolder') + + SettingsGet('SpamFolder') + + SettingsGet('TrashFolder') + + SettingsGet('ArchiveFolder') + + SettingsGet('NullFolder')) ) { Settings.set('SentFolder', this.SystemFolders[ServerFolderType.SENT] || null); Settings.set('DraftFolder', this.SystemFolders[ServerFolderType.DRAFTS] || null); @@ -135,11 +135,11 @@ export class FolderCollectionModel extends AbstractCollectionModel update = true; } - FolderStore.sentFolder(normalizeFolder(Settings.get('SentFolder'))); - FolderStore.draftFolder(normalizeFolder(Settings.get('DraftFolder'))); - FolderStore.spamFolder(normalizeFolder(Settings.get('SpamFolder'))); - FolderStore.trashFolder(normalizeFolder(Settings.get('TrashFolder'))); - FolderStore.archiveFolder(normalizeFolder(Settings.get('ArchiveFolder'))); + FolderStore.sentFolder(normalizeFolder(SettingsGet('SentFolder'))); + FolderStore.draftFolder(normalizeFolder(SettingsGet('DraftFolder'))); + FolderStore.spamFolder(normalizeFolder(SettingsGet('SpamFolder'))); + FolderStore.trashFolder(normalizeFolder(SettingsGet('TrashFolder'))); + FolderStore.archiveFolder(normalizeFolder(SettingsGet('ArchiveFolder'))); if (update) { rl.app.Remote.saveSystemFolders(()=>{}, { @@ -301,7 +301,7 @@ export class FolderModel extends AbstractModel { canBeDeleted: () => !folder.isSystemFolder() && !folder.subFolders.length, - canBeSubscribed: () => !folder.isSystemFolder() && folder.selectable && rl.settings.app('useImapSubscribe'), + canBeSubscribed: () => !folder.isSystemFolder() && folder.selectable && Settings.app('useImapSubscribe'), canBeSelected: () => !folder.isSystemFolder() && folder.selectable, diff --git a/dev/Remote/AbstractFetch.js b/dev/Remote/AbstractFetch.js index c317cc4a7..ba14c8b8c 100644 --- a/dev/Remote/AbstractFetch.js +++ b/dev/Remote/AbstractFetch.js @@ -1,4 +1,5 @@ import { StorageResultType, Notification } from 'Common/Enums'; +import { Settings } from 'Common/Globals'; import { pInt, pString } from 'Common/Utils'; import { serverRequest } from 'Common/Links'; @@ -11,7 +12,7 @@ const getURL = (add = '') => serverRequest('Json') + add, updateToken = data => { if (data.UpdateToken) { rl.hash.set(); - rl.settings.set('AuthAccountHash', data.UpdateToken); + Settings.set('AuthAccountHash', data.UpdateToken); } }, diff --git a/dev/Remote/User/Fetch.js b/dev/Remote/User/Fetch.js index daee69c86..68ea80c55 100644 --- a/dev/Remote/User/Fetch.js +++ b/dev/Remote/User/Fetch.js @@ -8,6 +8,7 @@ import { MessageFlagsCache } from 'Common/Cache'; +import { SettingsGet } from 'Common/Globals'; import { SUB_QUERY_PREFIX } from 'Common/Links'; import AppStore from 'Stores/User/App'; @@ -31,16 +32,15 @@ class RemoteUserFetch extends AbstractFetchRemote { * @param {?Function} fCallback */ folders(fCallback) { - const settingsGet = rl.settings.get; this.defaultRequest( fCallback, 'Folders', { - SentFolder: settingsGet('SentFolder'), - DraftFolder: settingsGet('DraftFolder'), - SpamFolder: settingsGet('SpamFolder'), - TrashFolder: settingsGet('TrashFolder'), - ArchiveFolder: settingsGet('ArchiveFolder') + SentFolder: SettingsGet('SentFolder'), + DraftFolder: SettingsGet('DraftFolder'), + SpamFolder: SettingsGet('SpamFolder'), + TrashFolder: SettingsGet('TrashFolder'), + ArchiveFolder: SettingsGet('ArchiveFolder') }, null, '', diff --git a/dev/Settings/Admin/About.js b/dev/Settings/Admin/About.js index 88b8f9e64..6a9fed445 100644 --- a/dev/Settings/Admin/About.js +++ b/dev/Settings/Admin/About.js @@ -1,7 +1,8 @@ import ko from 'ko'; +import { Settings } from 'Common/Globals'; export class AboutAdminSettings { constructor() { - this.version = ko.observable(rl.settings.app('version')); + this.version = ko.observable(Settings.app('version')); } } diff --git a/dev/Settings/Admin/Branding.js b/dev/Settings/Admin/Branding.js index a9856aa6e..96c4d4f6a 100644 --- a/dev/Settings/Admin/Branding.js +++ b/dev/Settings/Admin/Branding.js @@ -1,15 +1,15 @@ import ko from 'ko'; +import { SettingsGet } from 'Common/Globals'; import { settingsSaveHelperSimpleFunction } from 'Common/Utils'; import Remote from 'Remote/Admin/Fetch'; export class BrandingAdminSettings { constructor() { - const settingsGet = rl.settings.get; - this.title = ko.observable(settingsGet('Title')).idleTrigger(); - this.loadingDesc = ko.observable(settingsGet('LoadingDescription')).idleTrigger(); - this.faviconUrl = ko.observable(settingsGet('FaviconUrl')).idleTrigger(); + this.title = ko.observable(SettingsGet('Title')).idleTrigger(); + this.loadingDesc = ko.observable(SettingsGet('LoadingDescription')).idleTrigger(); + this.faviconUrl = ko.observable(SettingsGet('FaviconUrl')).idleTrigger(); } onBuild() { diff --git a/dev/Settings/Admin/Contacts.js b/dev/Settings/Admin/Contacts.js index 26bb29e3b..7bd3339d6 100644 --- a/dev/Settings/Admin/Contacts.js +++ b/dev/Settings/Admin/Contacts.js @@ -1,25 +1,24 @@ import ko from 'ko'; +import { SaveSettingsStep, StorageResultType } from 'Common/Enums'; +import { SettingsGet } from 'Common/Globals'; import { settingsSaveHelperSimpleFunction, defaultOptionsAfterRender } from 'Common/Utils'; -import { SaveSettingsStep, StorageResultType } from 'Common/Enums'; import Remote from 'Remote/Admin/Fetch'; import { decorateKoCommands } from 'Knoin/Knoin'; -const settingsGet = rl.settings.get; - export class ContactsAdminSettings { constructor() { this.defaultOptionsAfterRender = defaultOptionsAfterRender; ko.addObservablesTo(this, { - enableContacts: !!settingsGet('ContactsEnable'), - contactsSync: !!settingsGet('ContactsSync'), + enableContacts: !!SettingsGet('ContactsEnable'), + contactsSync: !!SettingsGet('ContactsSync'), contactsType: '', - pdoDsn: settingsGet('ContactsPdoDsn'), - pdoUser: settingsGet('ContactsPdoUser'), - pdoPassword: settingsGet('ContactsPdoPassword'), + pdoDsn: SettingsGet('ContactsPdoDsn'), + pdoUser: SettingsGet('ContactsPdoUser'), + pdoPassword: SettingsGet('ContactsPdoPassword'), pdoDsnTrigger: SaveSettingsStep.Idle, pdoUserTrigger: SaveSettingsStep.Idle, @@ -32,7 +31,7 @@ export class ContactsAdminSettings { testContactsErrorMessage: '' }); - const supportedTypes = settingsGet('supportedPdoDrivers') || [], + const supportedTypes = SettingsGet('supportedPdoDrivers') || [], types = [{ id:'sqlite', name:'SQLite' @@ -71,7 +70,7 @@ export class ContactsAdminSettings { this.testContactsErrorMessage(''); }); - this.contactsType(settingsGet('ContactsPdoType')); + this.contactsType(SettingsGet('ContactsPdoType')); this.onTestContactsResponse = this.onTestContactsResponse.bind(this); @@ -162,7 +161,7 @@ export class ContactsAdminSettings { }); }); - this.contactsType(settingsGet('ContactsPdoType')); + this.contactsType(SettingsGet('ContactsPdoType')); }, 50); } } diff --git a/dev/Settings/Admin/General.js b/dev/Settings/Admin/General.js index 6bcf71a83..99dd87d32 100644 --- a/dev/Settings/Admin/General.js +++ b/dev/Settings/Admin/General.js @@ -8,6 +8,7 @@ import { } from 'Common/Utils'; import { SaveSettingsStep } from 'Common/Enums'; +import { Settings, SettingsGet } from 'Common/Globals'; import { reload as translatorReload, convertLangName } from 'Common/Translator'; import { showScreenPopup } from 'Knoin/Knoin'; @@ -20,17 +21,15 @@ import { AppAdminStore } from 'Stores/Admin/App'; import { CapaAdminStore } from 'Stores/Admin/Capa'; import LanguagesPopupView from 'View/Popup/Languages'; -const settingsGet = rl.settings.get; - export class GeneralAdminSettings { constructor() { this.language = LanguageStore.language; this.languages = LanguageStore.languages; - const aLanguagesAdmin = rl.settings.app('languagesAdmin'); + const aLanguagesAdmin = Settings.app('languagesAdmin'); this.languagesAdmin = ko.observableArray(Array.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []); this.languageAdmin = ko - .observable(settingsGet('LanguageAdmin')) + .observable(SettingsGet('LanguageAdmin')) .extend({ limitedList: this.languagesAdmin }); this.theme = ThemeStore.theme; @@ -44,8 +43,8 @@ export class GeneralAdminSettings { this.capaTemplates = CapaAdminStore.templates; ko.addObservablesTo(this, { - allowLanguagesOnSettings: !!settingsGet('AllowLanguagesOnSettings'), - newMoveToFolder: !!settingsGet('NewMoveToFolder'), + allowLanguagesOnSettings: !!SettingsGet('AllowLanguagesOnSettings'), + newMoveToFolder: !!SettingsGet('NewMoveToFolder'), attachmentLimitTrigger: SaveSettingsStep.Idle, languageTrigger: SaveSettingsStep.Idle, themeTrigger: SaveSettingsStep.Idle @@ -56,10 +55,10 @@ export class GeneralAdminSettings { this.dataFolderAccess = AppAdminStore.dataFolderAccess; this.mainAttachmentLimit = ko - .observable(pInt(settingsGet('AttachmentLimit')) / (1024 * 1024)) + .observable(pInt(SettingsGet('AttachmentLimit')) / (1024 * 1024)) .extend({ debounce: 500 }); - this.uploadData = settingsGet('PhpUploadSizes'); + this.uploadData = SettingsGet('PhpUploadSizes'); this.uploadDataDesc = this.uploadData && (this.uploadData.upload_max_filesize || this.uploadData.post_max_size) ? [ @@ -178,7 +177,7 @@ export class GeneralAdminSettings { showScreenPopup(LanguagesPopupView, [ this.languageAdmin, this.languagesAdmin(), - settingsGet('UserLanguageAdmin') + SettingsGet('UserLanguageAdmin') ]); } } diff --git a/dev/Settings/Admin/Login.js b/dev/Settings/Admin/Login.js index 28959739e..e3f617572 100644 --- a/dev/Settings/Admin/Login.js +++ b/dev/Settings/Admin/Login.js @@ -1,20 +1,20 @@ import ko from 'ko'; +import { Settings, SettingsGet } from 'Common/Globals'; import { settingsSaveHelperSimpleFunction } from 'Common/Utils'; import Remote from 'Remote/Admin/Fetch'; export class LoginAdminSettings { constructor() { - const settingsGet = rl.settings.get; ko.addObservablesTo(this, { - determineUserLanguage: !!settingsGet('DetermineUserLanguage'), - determineUserDomain: !!settingsGet('DetermineUserDomain'), - allowLanguagesOnLogin: !!settingsGet('AllowLanguagesOnLogin'), - hideSubmitButton: !!rl.settings.app('hideSubmitButton') + determineUserLanguage: !!SettingsGet('DetermineUserLanguage'), + determineUserDomain: !!SettingsGet('DetermineUserDomain'), + allowLanguagesOnLogin: !!SettingsGet('AllowLanguagesOnLogin'), + hideSubmitButton: !!Settings.app('hideSubmitButton') }); - this.defaultDomain = ko.observable(settingsGet('LoginDefaultDomain')).idleTrigger(); + this.defaultDomain = ko.observable(SettingsGet('LoginDefaultDomain')).idleTrigger(); } onBuild() { diff --git a/dev/Settings/Admin/Plugins.js b/dev/Settings/Admin/Plugins.js index 2630b95e7..7d7199b5a 100644 --- a/dev/Settings/Admin/Plugins.js +++ b/dev/Settings/Admin/Plugins.js @@ -1,6 +1,7 @@ import ko from 'ko'; import { StorageResultType, Notification } from 'Common/Enums'; +import { SettingsGet } from 'Common/Globals'; import { getNotification } from 'Common/Translator'; import { showScreenPopup } from 'Knoin/Knoin'; @@ -13,7 +14,7 @@ import { PluginPopupView } from 'View/Popup/Plugin'; export class PluginsAdminSettings { constructor() { - this.enabledPlugins = ko.observable(!!rl.settings.get('EnabledPlugins')); + this.enabledPlugins = ko.observable(!!SettingsGet('EnabledPlugins')); this.plugins = PluginAdminStore; this.pluginsError = PluginAdminStore.error; diff --git a/dev/Settings/Admin/Security.js b/dev/Settings/Admin/Security.js index 4e1e420b8..209a985ae 100644 --- a/dev/Settings/Admin/Security.js +++ b/dev/Settings/Admin/Security.js @@ -1,6 +1,7 @@ import ko from 'ko'; import { StorageResultType } from 'Common/Enums'; +import { SettingsGet } from 'Common/Globals'; import { AppAdminStore } from 'Stores/Admin/App'; import { CapaAdminStore } from 'Stores/Admin/Capa'; @@ -9,8 +10,6 @@ import Remote from 'Remote/Admin/Fetch'; import { decorateKoCommands } from 'Knoin/Knoin'; -const settingsGet = rl.settings.get; - export class SecurityAdminSettings { constructor() { this.weakPassword = AppAdminStore.weakPassword; @@ -21,16 +20,16 @@ export class SecurityAdminSettings { this.capaTwoFactorAuthForce = CapaAdminStore.twoFactorAuthForce; ko.addObservablesTo(this, { - useLocalProxyForExternalImages: !!rl.settings.get('UseLocalProxyForExternalImages'), + useLocalProxyForExternalImages: !!SettingsGet('UseLocalProxyForExternalImages'), - verifySslCertificate: !!settingsGet('VerifySslCertificate'), - allowSelfSigned: !!settingsGet('AllowSelfSigned'), + verifySslCertificate: !!SettingsGet('VerifySslCertificate'), + allowSelfSigned: !!SettingsGet('AllowSelfSigned'), isTwoFactorDropperShown: false, twoFactorDropperUser: '', twoFactorDropperUserFocused: false, - adminLogin: settingsGet('AdminLogin'), + adminLogin: SettingsGet('AdminLogin'), adminLoginError: false, adminPassword: '', adminPasswordNew: '', diff --git a/dev/Settings/User/Accounts.js b/dev/Settings/User/Accounts.js index 81417a8a8..ba75cdbba 100644 --- a/dev/Settings/User/Accounts.js +++ b/dev/Settings/User/Accounts.js @@ -1,6 +1,7 @@ import ko from 'ko'; import { Capa, StorageResultType } from 'Common/Enums'; +import { Settings } from 'Common/Globals'; import AccountStore from 'Stores/User/Account'; import { IdentityUserStore } from 'Stores/User/Identity'; @@ -13,8 +14,8 @@ import { IdentityPopupView } from 'View/Popup/Identity'; export class AccountsUserSettings { constructor() { - this.allowAdditionalAccount = rl.settings.capa(Capa.AdditionalAccounts); - this.allowIdentities = rl.settings.capa(Capa.Identities); + this.allowAdditionalAccount = Settings.capa(Capa.AdditionalAccounts); + this.allowIdentities = Settings.capa(Capa.Identities); this.accounts = AccountStore.accounts; this.identities = IdentityUserStore; diff --git a/dev/Settings/User/General.js b/dev/Settings/User/General.js index 3df2da0e0..bba24a97e 100644 --- a/dev/Settings/User/General.js +++ b/dev/Settings/User/General.js @@ -1,12 +1,10 @@ import ko from 'ko'; import { MESSAGES_PER_PAGE_VALUES } from 'Common/Consts'; - import { SaveSettingsStep } from 'Common/Enums'; import { EditorDefaultType, Layout } from 'Common/EnumsUser'; - +import { SettingsGet } from 'Common/Globals'; import { settingsSaveHelperSimpleFunction } from 'Common/Utils'; - import { i18n, trigger as translatorTrigger, reload as translatorReload, convertLangName } from 'Common/Translator'; import { showScreenPopup } from 'Knoin/Knoin'; @@ -44,7 +42,7 @@ export class GeneralUserSettings { this.threadsAllowed = AppStore.threadsAllowed; this.useThreads = SettingsStore.useThreads; this.replySameFolder = SettingsStore.replySameFolder; - this.allowLanguagesOnSettings = !!rl.settings.get('AllowLanguagesOnSettings'); + this.allowLanguagesOnSettings = !!SettingsGet('AllowLanguagesOnSettings'); this.languageFullName = ko.computed(() => convertLangName(this.language())); this.languageTrigger = ko.observable(SaveSettingsStep.Idle).extend({ debounce: 100 }); diff --git a/dev/Settings/User/Security.js b/dev/Settings/User/Security.js index 1fde1baa5..2d07a9244 100644 --- a/dev/Settings/User/Security.js +++ b/dev/Settings/User/Security.js @@ -2,6 +2,7 @@ import ko from 'ko'; import { pInt, settingsSaveHelperSimpleFunction } from 'Common/Utils'; import { Capa, SaveSettingsStep } from 'Common/Enums'; +import { Settings } from 'Common/Globals'; import { i18n, trigger as translatorTrigger } from 'Common/Translator'; import { showScreenPopup } from 'Knoin/Knoin'; @@ -14,8 +15,8 @@ import { TwoFactorConfigurationPopupView } from 'View/Popup/TwoFactorConfigurati export class SecurityUserSettings { constructor() { - this.capaAutoLogout = rl.settings.capa(Capa.AutoLogout); - this.capaTwoFactor = rl.settings.capa(Capa.TwoFactor); + this.capaAutoLogout = Settings.capa(Capa.AutoLogout); + this.capaTwoFactor = Settings.capa(Capa.TwoFactor); this.autoLogout = SettinsStore.autoLogout; this.autoLogout.trigger = ko.observable(SaveSettingsStep.Idle); diff --git a/dev/Settings/User/Themes.js b/dev/Settings/User/Themes.js index 23495f88c..44f1a44d1 100644 --- a/dev/Settings/User/Themes.js +++ b/dev/Settings/User/Themes.js @@ -4,7 +4,7 @@ import { SaveSettingsStep, UploadErrorCode, Capa } from 'Common/Enums'; import { changeTheme, convertThemeName } from 'Common/Utils'; import { userBackground, themePreviewLink, serverRequest } from 'Common/Links'; import { i18n } from 'Common/Translator'; -import { doc, $htmlCL } from 'Common/Globals'; +import { doc, $htmlCL, Settings } from 'Common/Globals'; import { ThemeStore } from 'Stores/Theme'; @@ -23,7 +23,7 @@ export class ThemesUserSettings { this.background.loading = ko.observable(false); this.background.error = ko.observable(''); - this.capaUserBackground = ko.observable(rl.settings.capa(Capa.UserBackground)); + this.capaUserBackground = ko.observable(Settings.capa(Capa.UserBackground)); this.themeTrigger = ko.observable(SaveSettingsStep.Idle).extend({ debounce: 100 }); diff --git a/dev/Stores/Admin/App.js b/dev/Stores/Admin/App.js index 6f89a18bf..26d79ed4d 100644 --- a/dev/Stores/Admin/App.js +++ b/dev/Stores/Admin/App.js @@ -1,13 +1,14 @@ import ko from 'ko'; +import { SettingsGet } from 'Common/Globals'; export const AppAdminStore = { weakPassword: ko.observable(false), dataFolderAccess: ko.observable(false), populate: function() { - this.weakPassword(!!rl.settings.get('WeakPassword')); + this.weakPassword(!!SettingsGet('WeakPassword')); /* - rl.settings.get('WeakPassword') + SettingsGet('WeakPassword') && fetch('./data/VERSION?' + Math.random()).then(() => this.dataFolderAccess(true)); */ } diff --git a/dev/Stores/Admin/Capa.js b/dev/Stores/Admin/Capa.js index ea1abbd41..a16deed85 100644 --- a/dev/Stores/Admin/Capa.js +++ b/dev/Stores/Admin/Capa.js @@ -1,9 +1,10 @@ import ko from 'ko'; import { Capa } from 'Common/Enums'; +import { Settings } from 'Common/Globals'; export const CapaAdminStore = { populate: function() { - let capa = rl.settings.capa; + const capa = Settings.capa; this.additionalAccounts(capa(Capa.AdditionalAccounts)); this.identities(capa(Capa.Identities)); this.attachmentThumbnails(capa(Capa.AttachmentThumbnails)); diff --git a/dev/Stores/Language.js b/dev/Stores/Language.js index 4e1c6e90b..af09e17d9 100644 --- a/dev/Stores/Language.js +++ b/dev/Stores/Language.js @@ -1,15 +1,15 @@ import ko from 'ko'; +import { Settings, SettingsGet } from 'Common/Globals'; export const LanguageStore = { languages: ko.observableArray(), userLanguage: ko.observable(''), populate: function() { - const Settings = rl.settings, - aLanguages = Settings.app('languages'); + const aLanguages = Settings.app('languages'); this.languages(Array.isArray(aLanguages) ? aLanguages : []); - this.language(Settings.get('Language')); - this.userLanguage(Settings.get('UserLanguage')); + this.language(SettingsGet('Language')); + this.userLanguage(SettingsGet('UserLanguage')); } } diff --git a/dev/Stores/Theme.js b/dev/Stores/Theme.js index fa1b1f0c0..e0d27e03f 100644 --- a/dev/Stores/Theme.js +++ b/dev/Stores/Theme.js @@ -1,5 +1,5 @@ import ko from 'ko'; -import { $htmlCL, leftPanelDisabled } from 'Common/Globals'; +import { $htmlCL, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals'; export const ThemeStore = { themes: ko.observableArray(), @@ -8,14 +8,13 @@ export const ThemeStore = { isMobile: ko.observable($htmlCL.contains('rl-mobile')), populate: function(){ - const Settings = rl.settings, - themes = Settings.app('themes'); + const themes = Settings.app('themes'); this.themes(Array.isArray(themes) ? themes : []); - this.theme(Settings.get('Theme')); + this.theme(SettingsGet('Theme')); if (!this.isMobile()) { - this.userBackgroundName(Settings.get('UserBackgroundName')); - this.userBackgroundHash(Settings.get('UserBackgroundHash')); + this.userBackgroundName(SettingsGet('UserBackgroundName')); + this.userBackgroundHash(SettingsGet('UserBackgroundHash')); } leftPanelDisabled(this.isMobile()); diff --git a/dev/Stores/User/Account.js b/dev/Stores/User/Account.js index d3cb97e29..0cafc5fee 100644 --- a/dev/Stores/User/Account.js +++ b/dev/Stores/User/Account.js @@ -1,4 +1,5 @@ import ko from 'ko'; +import { SettingsGet } from 'Common/Globals'; class AccountUserStore { constructor() { @@ -27,8 +28,8 @@ class AccountUserStore { } populate() { - this.email(rl.settings.get('Email')); - this.parentEmail(rl.settings.get('ParentEmail')); + this.email(SettingsGet('Email')); + this.parentEmail(SettingsGet('ParentEmail')); } } diff --git a/dev/Stores/User/App.js b/dev/Stores/User/App.js index 93113f705..80d5401ab 100644 --- a/dev/Stores/User/App.js +++ b/dev/Stores/User/App.js @@ -1,7 +1,7 @@ import ko from 'ko'; import { KeyState } from 'Common/Enums'; import { Focused } from 'Common/EnumsUser'; -import { keyScope, leftPanelDisabled, Settings } from 'Common/Globals'; +import { keyScope, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals'; import { ThemeStore } from 'Stores/Theme'; class AppUserStore { @@ -48,18 +48,18 @@ class AppUserStore { } populate() { - this.projectHash(Settings.get('ProjectHash')); + this.projectHash(SettingsGet('ProjectHash')); - this.contactsAutosave(!!Settings.get('ContactsAutosave')); - this.useLocalProxyForExternalImages(!!Settings.get('UseLocalProxyForExternalImages')); + this.contactsAutosave(!!SettingsGet('ContactsAutosave')); + this.useLocalProxyForExternalImages(!!SettingsGet('UseLocalProxyForExternalImages')); - this.contactsIsAllowed(!!Settings.get('ContactsIsAllowed')); + this.contactsIsAllowed(!!SettingsGet('ContactsIsAllowed')); const attachmentsActions = Settings.app('attachmentsActions'); this.attachmentsActions(Array.isNotEmpty(attachmentsActions) ? attachmentsActions : []); - this.devEmail = Settings.get('DevEmail'); - this.devPassword = Settings.get('DevPassword'); + this.devEmail = SettingsGet('DevEmail'); + this.devPassword = SettingsGet('DevPassword'); } } diff --git a/dev/Stores/User/Contact.js b/dev/Stores/User/Contact.js index d118b2139..04c6e75a3 100644 --- a/dev/Stores/User/Contact.js +++ b/dev/Stores/User/Contact.js @@ -1,4 +1,5 @@ import ko from 'ko'; +import { SettingsGet } from 'Common/Globals'; class ContactUserStore { constructor() { @@ -19,13 +20,12 @@ class ContactUserStore { } populate() { - const settingsGet = rl.settings.get; - this.allowContactsSync(!!settingsGet('ContactsSyncIsAllowed')); - this.enableContactsSync(!!settingsGet('EnableContactsSync')); + this.allowContactsSync(!!SettingsGet('ContactsSyncIsAllowed')); + this.enableContactsSync(!!SettingsGet('EnableContactsSync')); - this.contactsSyncUrl(settingsGet('ContactsSyncUrl')); - this.contactsSyncUser(settingsGet('ContactsSyncUser')); - this.contactsSyncPass(settingsGet('ContactsSyncPassword')); + this.contactsSyncUrl(SettingsGet('ContactsSyncUrl')); + this.contactsSyncUser(SettingsGet('ContactsSyncUser')); + this.contactsSyncPass(SettingsGet('ContactsSyncPassword')); } } diff --git a/dev/Stores/User/Folder.js b/dev/Stores/User/Folder.js index f27cd71f2..8aa15690f 100644 --- a/dev/Stores/User/Folder.js +++ b/dev/Stores/User/Folder.js @@ -4,6 +4,7 @@ import { FolderType } from 'Common/EnumsUser'; import { UNUSED_OPTION_VALUE } from 'Common/Consts'; import { folderListOptionsBuilder } from 'Common/UtilsUser'; import { getFolderInboxName, getFolderFromCacheList } from 'Common/Cache'; +import { SettingsGet } from 'Common/Globals'; class FolderUserStore { constructor() { @@ -40,7 +41,7 @@ class FolderUserStore { this.currentFolder = ko.observable(null).extend({ toggleSubscribeProperty: [this, 'selected'] }); - this.sieveAllowFileintoInbox = !!rl.settings.get('SieveAllowFileintoInbox'); + this.sieveAllowFileintoInbox = !!SettingsGet('SieveAllowFileintoInbox'); this.draftFolderNotEnabled = ko.computed( () => !this.draftFolder() || UNUSED_OPTION_VALUE === this.draftFolder() diff --git a/dev/Stores/User/Notification.js b/dev/Stores/User/Notification.js index 11ba84c65..e60939bd8 100644 --- a/dev/Stores/User/Notification.js +++ b/dev/Stores/User/Notification.js @@ -1,6 +1,7 @@ import ko from 'ko'; import Audio from 'Common/Audio'; +import { SettingsGet } from 'Common/Globals'; import * as Links from 'Common/Links'; /** @@ -102,8 +103,8 @@ class NotificationUserStore { } populate() { - this.enableSoundNotification(!!rl.settings.get('SoundNotification')); - this.enableDesktopNotification(!!rl.settings.get('DesktopNotifications')); + this.enableSoundNotification(!!SettingsGet('SoundNotification')); + this.enableDesktopNotification(!!SettingsGet('DesktopNotifications')); } } diff --git a/dev/Stores/User/Settings.js b/dev/Stores/User/Settings.js index edefec1df..8eae70437 100644 --- a/dev/Stores/User/Settings.js +++ b/dev/Stores/User/Settings.js @@ -3,7 +3,7 @@ import ko from 'ko'; import { MESSAGES_PER_PAGE_VALUES } from 'Common/Consts'; import { Layout, EditorDefaultType } from 'Common/EnumsUser'; import { pInt } from 'Common/Utils'; -import { $htmlCL, Settings } from 'Common/Globals'; +import { $htmlCL, SettingsGet } from 'Common/Globals'; import { ThemeStore } from 'Stores/Theme'; class SettingsUserStore { @@ -41,7 +41,7 @@ class SettingsUserStore { let iAutoLogoutTimer; this.delayLogout = (() => { clearTimeout(iAutoLogoutTimer); - if (0 < this.autoLogout() && !Settings.get('AccountSignMe')) { + if (0 < this.autoLogout() && !SettingsGet('AccountSignMe')) { iAutoLogoutTimer = setTimeout( rl.app.logout, this.autoLogout() * 60000 @@ -60,19 +60,18 @@ class SettingsUserStore { } populate() { - const settingsGet = Settings.get; - this.layout(pInt(settingsGet('Layout'))); - this.editorDefaultType(settingsGet('EditorDefaultType')); + this.layout(pInt(SettingsGet('Layout'))); + this.editorDefaultType(SettingsGet('EditorDefaultType')); - this.autoLogout(pInt(settingsGet('AutoLogout'))); - this.messagesPerPage(settingsGet('MPP')); + this.autoLogout(pInt(SettingsGet('AutoLogout'))); + this.messagesPerPage(SettingsGet('MPP')); - this.showImages(!!settingsGet('ShowImages')); - this.removeColors(!!settingsGet('RemoveColors')); - this.useCheckboxesInList(!!(ThemeStore.isMobile() || settingsGet('UseCheckboxesInList'))); - this.allowDraftAutosave(!!settingsGet('AllowDraftAutosave')); - this.useThreads(!!settingsGet('UseThreads')); - this.replySameFolder(!!settingsGet('ReplySameFolder')); + this.showImages(!!SettingsGet('ShowImages')); + this.removeColors(!!SettingsGet('RemoveColors')); + this.useCheckboxesInList(!!(ThemeStore.isMobile() || SettingsGet('UseCheckboxesInList'))); + this.allowDraftAutosave(!!SettingsGet('AllowDraftAutosave')); + this.useThreads(!!SettingsGet('UseThreads')); + this.replySameFolder(!!SettingsGet('ReplySameFolder')); this.delayLogout(); } diff --git a/dev/View/Admin/Login.js b/dev/View/Admin/Login.js index 48065b84a..e2060a751 100644 --- a/dev/View/Admin/Login.js +++ b/dev/View/Admin/Login.js @@ -1,6 +1,7 @@ import ko from 'ko'; import { StorageResultType, Notification } from 'Common/Enums'; +import { Settings } from 'Common/Globals'; import { getNotification } from 'Common/Translator'; import Remote from 'Remote/Admin/Fetch'; @@ -12,7 +13,7 @@ class LoginAdminView extends AbstractViewCenter { constructor() { super('Admin/Login', 'AdminLogin'); - this.hideSubmitButton = rl.settings.app('hideSubmitButton'); + this.hideSubmitButton = Settings.app('hideSubmitButton'); this.addObservables({ login: '', diff --git a/dev/View/Admin/Settings/Pane.js b/dev/View/Admin/Settings/Pane.js index d72d4c548..93780de7d 100644 --- a/dev/View/Admin/Settings/Pane.js +++ b/dev/View/Admin/Settings/Pane.js @@ -8,13 +8,13 @@ import { PackageAdminStore } from 'Stores/Admin/Package'; import { AbstractViewRight } from 'Knoin/AbstractViews'; -import { leftPanelDisabled } from 'Common/Globals'; +import { leftPanelDisabled, Settings } from 'Common/Globals'; class PaneSettingsAdminView extends AbstractViewRight { constructor() { super('Admin/Settings/Pane', 'AdminPane'); - this.version = ko.observable(rl.settings.app('version')); + this.version = ko.observable(Settings.app('version')); this.leftPanelDisabled = leftPanelDisabled; diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 7890b6802..f55676a19 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -22,7 +22,7 @@ import { serverRequest } from 'Common/Links'; import { i18n, getNotification, getUploadErrorDescByCode } from 'Common/Translator'; import { timestampToString } from 'Common/Momentor'; import { MessageFlagsCache, setFolderHash } from 'Common/Cache'; -import { Settings } from 'Common/Globals'; +import { Settings, SettingsGet } from 'Common/Globals'; import AppStore from 'Stores/User/App'; import SettingsStore from 'Stores/User/Settings'; @@ -1189,7 +1189,7 @@ class ComposePopupView extends AbstractViewPopup { initUploader() { if (this.composeUploaderButton()) { const uploadCache = {}, - attachmentSizeLimit = pInt(Settings.get('AttachmentLimit')), + attachmentSizeLimit = pInt(SettingsGet('AttachmentLimit')), oJua = new Jua({ action: serverRequest('Upload'), name: 'uploader', diff --git a/dev/View/Popup/FolderSystem.js b/dev/View/Popup/FolderSystem.js index e8cde9ab9..d2640a807 100644 --- a/dev/View/Popup/FolderSystem.js +++ b/dev/View/Popup/FolderSystem.js @@ -2,6 +2,7 @@ import ko from 'ko'; import { SetSystemFoldersNotification } from 'Common/EnumsUser'; import { UNUSED_OPTION_VALUE } from 'Common/Consts'; +import { Settings } from 'Common/Globals'; import { defaultOptionsAfterRender } from 'Common/Utils'; import { folderListOptionsBuilder } from 'Common/UtilsUser'; import { initOnStartOrLangChange, i18n } from 'Common/Translator'; @@ -50,7 +51,7 @@ class FolderSystemPopupView extends AbstractViewPopup { this.trashFolder = FolderStore.trashFolder; this.archiveFolder = FolderStore.archiveFolder; - const settingsSet = rl.settings.set, + const settingsSet = Settings.set, fSetSystemFolders = () => { settingsSet('SentFolder', FolderStore.sentFolder()); settingsSet('DraftFolder', FolderStore.draftFolder()); diff --git a/dev/View/Popup/TwoFactorConfiguration.js b/dev/View/Popup/TwoFactorConfiguration.js index 1497f0fcc..3b8ee024b 100644 --- a/dev/View/Popup/TwoFactorConfiguration.js +++ b/dev/View/Popup/TwoFactorConfiguration.js @@ -1,4 +1,5 @@ import { Capa, StorageResultType } from 'Common/Enums'; +import { Settings } from 'Common/Globals'; import { pString } from 'Common/Utils'; import { i18n, trigger as translatorTrigger } from 'Common/Translator'; @@ -33,7 +34,7 @@ class TwoFactorConfigurationPopupView extends AbstractViewPopup { viewEnable_: false }); - this.capaTwoFactor = rl.settings.capa(Capa.TwoFactor); + this.capaTwoFactor = Settings.capa(Capa.TwoFactor); this.addComputables({ viewEnable: { diff --git a/dev/View/User/AbstractSystemDropDown.js b/dev/View/User/AbstractSystemDropDown.js index b8f9cf72f..777e4c1ea 100644 --- a/dev/View/User/AbstractSystemDropDown.js +++ b/dev/View/User/AbstractSystemDropDown.js @@ -20,8 +20,8 @@ export class AbstractSystemDropDownUserView extends AbstractViewRight { constructor(name) { super(name, 'SystemDropDown'); - this.allowSettings = !!Settings.capa(Capa.Settings); - this.allowHelp = !!Settings.capa(Capa.Help); + this.allowSettings = Settings.capa(Capa.Settings); + this.allowHelp = Settings.capa(Capa.Help); this.currentAudio = AppStore.currentAudio; diff --git a/dev/View/User/Login.js b/dev/View/User/Login.js index 943cedf59..144300b21 100644 --- a/dev/View/User/Login.js +++ b/dev/View/User/Login.js @@ -19,7 +19,7 @@ import Remote from 'Remote/User/Fetch'; import { decorateKoCommands, showScreenPopup } from 'Knoin/Knoin'; import { AbstractViewCenter } from 'Knoin/AbstractViews'; -import { Settings } from 'Common/Globals'; +import { Settings, SettingsGet } from 'Common/Globals'; import { LanguagesPopupView } from 'View/Popup/Languages'; @@ -44,7 +44,7 @@ class LoginUserView extends AbstractViewCenter { this.hideSubmitButton = Settings.app('hideSubmitButton'); this.addObservables({ - loadingDesc: Settings.get('LoadingDescription'), + loadingDesc: SettingsGet('LoadingDescription'), email: '', password: '', @@ -73,7 +73,7 @@ class LoginUserView extends AbstractViewCenter { this.formError = ko.observable(false).extend({ falseTimeout: 500 }); - this.allowLanguagesOnLogin = !!Settings.get('AllowLanguagesOnLogin'); + this.allowLanguagesOnLogin = !!SettingsGet('AllowLanguagesOnLogin'); this.language = LanguageStore.language; this.languages = LanguageStore.languages; @@ -109,8 +109,8 @@ class LoginUserView extends AbstractViewCenter { signMeType: iValue => this.signMe(LoginSignMeType.DefaultOn === iValue) }); - if (Settings.get('AdditionalLoginError') && !this.submitError()) { - this.submitError(Settings.get('AdditionalLoginError')); + if (SettingsGet('AdditionalLoginError') && !this.submitError()) { + this.submitError(SettingsGet('AdditionalLoginError')); } decorateKoCommands(this, { @@ -207,7 +207,7 @@ class LoginUserView extends AbstractViewCenter { onBuild() { const signMeLocal = Local.get(ClientSideKeyName.LastSignMe), - signMe = (Settings.get('SignMe') || 'unused').toLowerCase(); + signMe = (SettingsGet('SignMe') || 'unused').toLowerCase(); switch (signMe) { case LoginSignMeTypeAsString.DefaultOff: diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 881f1811f..187ac839b 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -15,7 +15,7 @@ import { import { UNUSED_OPTION_VALUE } from 'Common/Consts'; -import { doc, leftPanelDisabled, moveAction, Settings } from 'Common/Globals'; +import { doc, leftPanelDisabled, moveAction, Settings, SettingsGet } from 'Common/Globals'; import { computedPaginatorHelper, showMessageComposer } from 'Common/UtilsUser'; import { FileInfo } from 'Common/File'; @@ -60,7 +60,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { this.iGoToUpUpOrDownDownTimeout = 0; - this.newMoveToFolder = !!Settings.get('NewMoveToFolder'); + this.newMoveToFolder = !!SettingsGet('NewMoveToFolder'); this.allowReload = Settings.capa(Capa.Reload); this.allowSearch = Settings.capa(Capa.Search); diff --git a/dev/bootstrap.js b/dev/bootstrap.js index 10834a00e..438d4c93b 100644 --- a/dev/bootstrap.js +++ b/dev/bootstrap.js @@ -1,4 +1,4 @@ -import { doc, elementById, dropdownVisibility } from 'Common/Globals'; +import { doc, elementById, dropdownVisibility, Settings } from 'Common/Globals'; import { StorageResultType } from 'Common/Enums'; import { i18n } from 'Common/Translator'; @@ -51,7 +51,7 @@ export default (App) => { }, reload: () => { rl.route.root(); - setTimeout(() => (rl.settings.app('inIframe') ? parent : window).location.reload(), 100); + setTimeout(() => (Settings.app('inIframe') ? parent : window).location.reload(), 100); }, off: () => hasher.changed.active = false, on: () => hasher.changed.active = true, @@ -91,7 +91,7 @@ export default (App) => { if (postData) { init.method = 'POST'; init.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; - postData.XToken = rl.settings.app('token'); + postData.XToken = Settings.app('token'); // init.body = JSON.stringify(postData); const formData = new FormData(), buildFormData = (formData, data, parentKey) => {