From aeb52756481ad1104834702c7116305a82d3893c Mon Sep 17 00:00:00 2001 From: djmaze Date: Fri, 4 Sep 2020 12:05:17 +0200 Subject: [PATCH] Improved boot.js with existing global window.rl Put dev/Storage/Settings.js in boots.js global rl.settings --- .eslintrc.js | 1 - README.md | 22 +++++----- dev/App/Abstract.js | 51 +++++------------------ dev/App/Admin.js | 6 +-- dev/App/User.js | 39 +++++++++-------- dev/Common/HtmlEditor.js | 7 ++-- dev/Common/Links.js | 38 +++++++---------- dev/Common/Plugins.js | 5 +-- dev/Promises/AbstractAjax.js | 18 ++++---- dev/Promises/User/Populator.js | 39 ++++++++--------- dev/Remote/AbstractAjax.js | 12 +++--- dev/Remote/User/Ajax.js | 12 +++--- dev/Screen/Admin/Login.js | 4 +- dev/Screen/Admin/Settings.js | 4 +- dev/Screen/User/Login.js | 4 +- dev/Screen/User/MailBox.js | 12 +++--- dev/Screen/User/Settings.js | 7 ++-- dev/Settings/Admin/About.js | 4 +- dev/Settings/Admin/Branding.js | 3 +- dev/Settings/Admin/Contacts.js | 3 +- dev/Settings/Admin/General.js | 3 +- dev/Settings/Admin/Login.js | 3 +- dev/Settings/Admin/Plugins.js | 3 +- dev/Settings/Admin/Security.js | 4 +- dev/Settings/User/Accounts.js | 6 +-- dev/Settings/User/Folders.js | 3 +- dev/Settings/User/Security.js | 6 +-- dev/Settings/User/Themes.js | 4 +- dev/Storage/Settings.js | 36 ---------------- dev/Stores/AbstractApp.js | 7 ++-- dev/Stores/Admin/App.js | 2 +- dev/Stores/Admin/Capa.js | 24 +++++------ dev/Stores/Language.js | 14 +++---- dev/Stores/Theme.js | 10 ++--- dev/Stores/User/Account.js | 5 +-- dev/Stores/User/App.js | 20 ++++----- dev/Stores/User/Contact.js | 12 +++--- dev/Stores/User/Folder.js | 4 +- dev/Stores/User/Notification.js | 5 +-- dev/Stores/User/Settings.js | 23 +++++----- dev/View/Admin/Login.js | 9 ++-- dev/View/Admin/Settings/Pane.js | 4 +- dev/View/Popup/Compose.js | 8 ++-- dev/View/Popup/Contacts.js | 6 +-- dev/View/Popup/FolderSystem.js | 14 +++---- dev/View/Popup/TwoFactorConfiguration.js | 4 +- dev/View/User/AbstractSystemDropDown.js | 11 ++--- dev/View/User/Login.js | 25 +++++------ dev/View/User/MailBox/FolderList.js | 6 +-- dev/View/User/MailBox/MessageList.js | 6 +-- dev/View/User/MailBox/MessageView.js | 9 ++-- dev/View/User/Settings/Menu.js | 4 +- dev/View/User/Settings/Pane.js | 4 +- dev/boot.js | 47 +++++++++++++-------- dev/bootstrap.js | 7 +--- rainloop/v/0.0.0/app/templates/Index.html | 5 +-- vendors/bootstrap/less/mixins.less | 10 +++++ 57 files changed, 284 insertions(+), 380 deletions(-) delete mode 100644 dev/Storage/Settings.js diff --git a/.eslintrc.js b/.eslintrc.js index c28de7e31..ee4b9c1cb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,7 +14,6 @@ module.exports = { }, globals: { // RainLoop - 'RainLoop': "readonly", 'rainloopI18N': "readonly", 'rainloopTEMPLATES': "readonly", 'rl': "readonly", diff --git a/README.md b/README.md index 7c10cfee5..e28c68cb3 100644 --- a/README.md +++ b/README.md @@ -86,23 +86,23 @@ Things might work in Edge 18, Firefox 50-62 and Chrome 54-68 due to one polyfill |js/* |1.14.0 |native | |----------- |--------: |--------: | -|admin.js |2.130.942 | 958.397 | -|app.js |4.184.455 |2.586.232 | -|boot.js | 671.522 | 6.782 | +|admin.js |2.130.942 | 942.565 | +|app.js |4.184.455 |2.563.204 | +|boot.js | 671.522 | 7.265 | |libs.js | 647.614 | 312.269 | |polyfills.js | 325.834 | 0 | -|TOTAL |7.960.367 |3.863.680 | +|TOTAL |7.960.367 |3.825.303 | |js/min/* |1.14.0 |native |gzip 1.14 |gzip |brotli | |--------------- |--------: |--------: |--------: |--------: |--------: | -|admin.min.js | 252.147 | 130.128 | 73.657 | 37.783 | 32.395 | -|app.min.js | 511.202 | 350.575 |140.462 | 92.070 | 73.949 | -|boot.min.js | 66.007 | 4.081 | 22.567 | 1.837 | 1.538 | +|admin.min.js | 252.147 | 129.058 | 73.657 | 37.631 | 32.250 | +|app.min.js | 511.202 | 350.074 |140.462 | 91.841 | 73.757 | +|boot.min.js | 66.007 | 4.274 | 22.567 | 1.934 | 1.635 | |libs.min.js | 572.545 | 295.776 |176.720 | 91.524 | 80.746 | |polyfills.min.js | 32.452 | 0 | 11.312 | 0 | 0 | -|TOTAL |1.434.353 | 780.560 |424.718 |223.214 |188.628 | +|TOTAL |1.434.353 | 779.182 |424.718 |222.930 |188.388 | -653.793 bytes (201.504 gzip) is not much, but it feels faster. +655.171 bytes (201.788 gzip) is not much, but it feels faster. ### CSS changes @@ -127,8 +127,8 @@ Things might work in Edge 18, Firefox 50-62 and Chrome 54-68 due to one polyfill |css/* |1.14.0 |native |gzip 1.14 |gzip |brotli | |-------------- |-------: |-------: |------: |------: |------: | -|app.css | 340.334 | 255.627 | 46,959 | 36.929 | 31.015 | -|app.min.css | 274.791 | 208.711 | 39,618 | 32.226 | 27.364 | +|app.css | 340.334 | 255.729 | 46,959 | 36.948 | 31.049 | +|app.min.css | 274.791 | 208.793 | 39,618 | 32.238 | 27.339 | ### PHP73 branch diff --git a/dev/App/Abstract.js b/dev/App/Abstract.js index 748333e23..3f65aa429 100644 --- a/dev/App/Abstract.js +++ b/dev/App/Abstract.js @@ -8,9 +8,8 @@ import { } from 'Common/Globals'; import { KeyState } from 'Common/Enums'; -import { root, rootAdmin, rootUser, populateAuthSuffix } from 'Common/Links'; +import { root, rootAdmin, rootUser } from 'Common/Links'; import { initOnStartOrLangChange, initNotificationLanguage } from 'Common/Translator'; -import * as Settings from 'Storage/Settings'; import LanguageStore from 'Stores/Language'; import ThemeStore from 'Stores/Theme'; @@ -18,6 +17,8 @@ import ThemeStore from 'Stores/Theme'; import { routeOff, setHash } from 'Knoin/Knoin'; import { AbstractBoot } from 'Knoin/AbstractBoot'; +const Settings = rl.settings; + class AbstractApp extends AbstractBoot { /** * @param {RemoteStorage|AdminRemoteStorage} Remote @@ -57,10 +58,6 @@ class AbstractApp extends AbstractBoot { return null; } - getApplicationConfiguration(name, default_) { - return this.applicationConfiguration[name] || default_; - } - /** * @param {string} link * @returns {boolean} @@ -79,40 +76,16 @@ class AbstractApp extends AbstractBoot { return true; } - /** - * @param {string} title - */ - setWindowTitle(title) { - title = null == title ? '' : '' + title; - if (Settings.settingsGet('Title')) { - title += (title ? ' - ' : '') + Settings.settingsGet('Title'); - } - - document.title = title; - } - redirectToAdminPanel() { - setTimeout(() => { - location.href = rootAdmin(); - }, 100); - } - - clearClientSideToken() { - if (RainLoop.hash.clear) { - RainLoop.hash.clear(); - } + setTimeout(() => location.href = rootAdmin(), 100); } /** * @param {string} token */ setClientSideToken(token) { - if (RainLoop.hash.set) { - RainLoop.hash.set(token); - - Settings.settingsSet('AuthAccountHash', token); - populateAuthSuffix(); - } + rl.hash.set(); + Settings.set('AuthAccountHash', token); } /** @@ -121,11 +94,11 @@ class AbstractApp extends AbstractBoot { * @param {boolean=} close = false */ loginAndLogoutReload(admin = false, logout = false, close = false) { - const inIframe = !!Settings.appSettingsGet('inIframe'), + const inIframe = !!Settings.app('inIframe'), logoutLink = admin ? rootAdmin() : rootUser(); if (logout) { - this.clearClientSideToken(); + rl.hash.clear(); } if (logout && close && window.close) { @@ -155,19 +128,15 @@ class AbstractApp extends AbstractBoot { } } - historyBack() { - history.back(); - } - bootstart() { - const mobile = Settings.appSettingsGet('mobile'); + const mobile = Settings.app('mobile'); ko.components.register('SaveTrigger', require('Component/SaveTrigger').default); ko.components.register('Input', require('Component/Input').default); ko.components.register('Select', require('Component/Select').default); ko.components.register('TextArea', require('Component/TextArea').default); - if (Settings.appSettingsGet('materialDesign') && !bMobileDevice) { + if (Settings.app('materialDesign') && !bMobileDevice) { ko.components.register('Checkbox', require('Component/MaterialDesign/Checkbox').default); ko.components.register('CheckboxSimple', require('Component/Checkbox').default); } else { diff --git a/dev/App/Admin.js b/dev/App/Admin.js index 6cba3eb0f..812707771 100644 --- a/dev/App/Admin.js +++ b/dev/App/Admin.js @@ -3,8 +3,6 @@ import ko from 'ko'; import { root } from 'Common/Links'; import { StorageResultType } from 'Common/Enums'; -import * as Settings from 'Storage/Settings'; - import AppStore from 'Stores/Admin/App'; import CapaStore from 'Stores/Admin/Capa'; import DomainStore from 'Stores/Admin/Domain'; @@ -113,7 +111,7 @@ class AdminApp extends AbstractApp { hideLoading(); - if (!Settings.appSettingsGet('allowAdminPanel')) { + if (!rl.settings.app('allowAdminPanel')) { routeOff(); setHash(root(), true); routeOff(); @@ -122,7 +120,7 @@ class AdminApp extends AbstractApp { location.href = '/' , 1); } else { - if (Settings.settingsGet('Auth')) { + if (rl.settings.get('Auth')) { startScreens([SettingsAdminScreen]); } else { startScreens([LoginAdminScreen]); diff --git a/dev/App/User.js b/dev/App/User.js index 1095d453c..a0204de5e 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -56,7 +56,6 @@ import MessageStore from 'Stores/User/Message'; import QuotaStore from 'Stores/User/Quota'; import * as Local from 'Storage/Client'; -import * as Settings from 'Storage/Settings'; import Remote from 'Remote/User/Ajax'; import Promises from 'Promises/User/Ajax'; @@ -75,7 +74,7 @@ import { hideLoading, routeOff, routeOn, setHash, startScreens, showScreenPopup import { AbstractApp } from 'App/Abstract'; -const doc = document; +const doc = document, Settings = rl.settings; class AppUser extends AbstractApp { constructor() { @@ -94,25 +93,25 @@ class AppUser extends AbstractApp { setInterval(() => { const currentTime = (new Date()).getTime(); if (currentTime > (lastTime + interval + 1000)) { - if (RainLoop.hash.check()) { + if (rl.hash.check()) { this.reload(); } Remote.jsVersion((sResult, oData) => { if (StorageResultType.Success === sResult && oData && !oData.Result) { this.reload(); } - }, Settings.appSettingsGet('version')); + }, Settings.app('version')); } lastTime = currentTime; }, interval); - if (RainLoop.hash.check()) { + if (rl.hash.check()) { this.reload(); } - if (Settings.settingsGet('UserBackgroundHash')) { + if (Settings.get('UserBackgroundHash')) { setTimeout(() => { - const img = userBackground(Settings.settingsGet('UserBackgroundHash')); + const img = userBackground(Settings.get('UserBackgroundHash')); if (img) { $htmlCL.add('UserBackground'); doc.body.style.backgroundImage = "url("+img+")"; @@ -126,7 +125,7 @@ class AppUser extends AbstractApp { } reload() { - if (parent && !!Settings.appSettingsGet('inIframe')) { + if (parent && !!Settings.app('inIframe')) { parent.location.reload(); } else { location.reload(); @@ -489,7 +488,7 @@ class AppUser extends AbstractApp { if (StorageResultType.Success === sResult && oData.Result) { const counts = {}, sAccountEmail = AccountStore.email(); - let parentEmail = Settings.settingsGet('ParentEmail') || sAccountEmail; + let parentEmail = Settings.get('ParentEmail') || sAccountEmail; if (Array.isArray(oData.Result.Accounts)) { AccountStore.accounts().forEach(oAccount => { @@ -901,7 +900,7 @@ class AppUser extends AbstractApp { this.loginAndLogoutReload( false, true, - 0 < (Settings.settingsGet('ParentEmail')||{length:0}).length + 0 < (Settings.get('ParentEmail')||{length:0}).length ); }); } @@ -932,27 +931,27 @@ class AppUser extends AbstractApp { AccountStore.populate(); ContactStore.populate(); - let contactsSyncInterval = pInt(Settings.settingsGet('ContactsSyncInterval')); + let contactsSyncInterval = pInt(Settings.get('ContactsSyncInterval')); - const startupUrl = pString(Settings.settingsGet('StartupUrl')); + const startupUrl = pString(Settings.get('StartupUrl')); if (window.progressJs) { progressJs.set(90); } - this.setWindowTitle(''); - if (Settings.settingsGet('Auth')) { + rl.setWindowTitle(); + if (Settings.get('Auth')) { $htmlCL.add('rl-user-auth'); if ( Settings.capa(Capa.TwoFactor) && Settings.capa(Capa.TwoFactorForce) && - Settings.settingsGet('RequireTwoFactor') + Settings.get('RequireTwoFactor') ) { this.bootend(); this.bootstartTwoFactorScreen(); } else { - this.setWindowTitle(i18n('TITLES/LOADING')); + rl.setWindowTitle(i18n('TITLES/LOADING')); // require.ensure([], function() { // require code splitting @@ -1041,7 +1040,7 @@ class AppUser extends AbstractApp { addEventListener('rl.auto-logout', () => this.logout()); if ( - !!Settings.settingsGet('AccountSignMe') && + !!Settings.get('AccountSignMe') && navigator.registerProtocolHandler && Settings.capa(Capa.Composer) ) { @@ -1050,12 +1049,12 @@ class AppUser extends AbstractApp { navigator.registerProtocolHandler( 'mailto', location.protocol + '//' + location.host + location.pathname + '?mailto&to=%s', - '' + (Settings.settingsGet('Title') || 'RainLoop') + '' + (Settings.get('Title') || 'RainLoop') ); } catch (e) {} // eslint-disable-line no-empty - if (Settings.settingsGet('MailToEmail')) { - mailToHelper(Settings.settingsGet('MailToEmail'), require('View/Popup/Compose')); + if (Settings.get('MailToEmail')) { + mailToHelper(Settings.get('MailToEmail'), require('View/Popup/Compose')); } }, 500); } diff --git a/dev/Common/HtmlEditor.js b/dev/Common/HtmlEditor.js index 07737c4ae..cad145881 100644 --- a/dev/Common/HtmlEditor.js +++ b/dev/Common/HtmlEditor.js @@ -1,5 +1,4 @@ import { EventKeyCode } from 'Common/Enums'; -import * as Settings from 'Storage/Settings'; /** * @type {Object} @@ -269,9 +268,9 @@ class HtmlEditor { if (this.element && !this.editor) { const initFunc = () => { const config = htmlEditorDefaultConfig, - language = Settings.settingsGet('Language'), - allowSource = !!Settings.appSettingsGet('allowHtmlEditorSourceButton'), - biti = !!Settings.appSettingsGet('allowHtmlEditorBitiButtons'); + language = rl.settings.get('Language'), + allowSource = !!rl.settings.app('allowHtmlEditorSourceButton'), + biti = !!rl.settings.app('allowHtmlEditorBitiButtons'); if ((allowSource || !biti) && !config.toolbarGroups.__cfgInited) { config.toolbarGroups.__cfgInited = true; diff --git a/dev/Common/Links.js b/dev/Common/Links.js index 70f3713c0..ac0f8255b 100644 --- a/dev/Common/Links.js +++ b/dev/Common/Links.js @@ -1,25 +1,19 @@ import { pString, pInt } from 'Common/Utils'; -import * as Settings from 'Storage/Settings'; -const ROOT = './', +const + Settings = rl.settings, + ROOT = './', HASH_PREFIX = '#/', SERVER_PREFIX = './?', SUB_QUERY_PREFIX = '&q[]=', - VERSION = Settings.appSettingsGet('version'), - WEB_PREFIX = Settings.appSettingsGet('webPath') || '', - VERSION_PREFIX = Settings.appSettingsGet('webVersionPath') || 'rainloop/v/' + VERSION + '/', + VERSION = Settings.app('version'), + WEB_PREFIX = Settings.app('webPath') || '', + VERSION_PREFIX = Settings.app('webVersionPath') || 'rainloop/v/' + VERSION + '/', STATIC_PREFIX = VERSION_PREFIX + 'static/', - ADMIN_HOST_USE = !!Settings.appSettingsGet('adminHostUse'), - ADMIN_PATH = Settings.appSettingsGet('adminPath') || 'admin'; + ADMIN_HOST_USE = !!Settings.app('adminHostUse'), + ADMIN_PATH = Settings.app('adminPath') || 'admin', -let AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0'; - -/** - * @returns {void} - */ -export function populateAuthSuffix() { - AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0'; -} + getHash = () => Settings.get('AuthAccountHash') || '0'; /** * @returns {string} @@ -57,7 +51,7 @@ export function rootUser() { * @returns {string} */ export function attachmentRaw(type, download, customSpecSuffix) { - customSpecSuffix = undefined === customSpecSuffix ? AUTH_PREFIX : customSpecSuffix; + customSpecSuffix = undefined === customSpecSuffix ? getHash() : customSpecSuffix; return ( SERVER_PREFIX + '/Raw/' + @@ -123,7 +117,7 @@ export function attachmentFramed(download, customSpecSuffix) { * @returns {string} */ export function serverRequest(type) { - return SERVER_PREFIX + '/' + type + '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/'; + return SERVER_PREFIX + '/' + type + '/' + SUB_QUERY_PREFIX + '/' + getHash() + '/'; } /** @@ -180,7 +174,7 @@ export function messageViewLink(requestHash) { '/Raw/' + SUB_QUERY_PREFIX + '/' + - AUTH_PREFIX + + getHash() + '/ViewAsPlain/' + SUB_QUERY_PREFIX + '/' + @@ -194,7 +188,7 @@ export function messageViewLink(requestHash) { */ export function messageDownloadLink(requestHash) { return ( - SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/Download/' + SUB_QUERY_PREFIX + '/' + requestHash + SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + getHash() + '/Download/' + SUB_QUERY_PREFIX + '/' + requestHash ); } @@ -220,7 +214,7 @@ export function publicLink(hash) { */ export function userBackground(hash) { return ( - SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/UserBackground/' + SUB_QUERY_PREFIX + '/' + hash + SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + getHash() + '/UserBackground/' + SUB_QUERY_PREFIX + '/' + hash ); } @@ -237,14 +231,14 @@ export function langLink(lang, isAdmin) { * @returns {string} */ export function exportContactsVcf() { - return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ContactsVcf/'; + return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + getHash() + '/ContactsVcf/'; } /** * @returns {string} */ export function exportContactsCsv() { - return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ContactsCsv/'; + return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + getHash() + '/ContactsCsv/'; } /** diff --git a/dev/Common/Plugins.js b/dev/Common/Plugins.js index fdf367c65..941353484 100644 --- a/dev/Common/Plugins.js +++ b/dev/Common/Plugins.js @@ -1,5 +1,4 @@ import { data as GlobalsData } from 'Common/Globals'; -import * as Settings from 'Storage/Settings'; const USER_VIEW_MODELS_HOOKS = [], ADMIN_VIEW_MODELS_HOOKS = []; @@ -9,7 +8,7 @@ const USER_VIEW_MODELS_HOOKS = [], * @returns {?} */ export function mainSettingsGet(name) { - return Settings.settingsGet(name); + return rl.settings.get(name); } /** @@ -60,7 +59,7 @@ export function runSettingsViewModelHooks(admin) { * @returns {?} */ export function settingsGet(pluginSection, name) { - let plugins = Settings.settingsGet('Plugins'); + let plugins = rl.settings.get('Plugins'); plugins = plugins && null != plugins[pluginSection] ? plugins[pluginSection] : null; return plugins ? (null == plugins[name] ? null : plugins[name]) : null; } diff --git a/dev/Promises/AbstractAjax.js b/dev/Promises/AbstractAjax.js index 95b7f4279..4c9a798d2 100644 --- a/dev/Promises/AbstractAjax.js +++ b/dev/Promises/AbstractAjax.js @@ -3,7 +3,6 @@ import { pInt, 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'; -import * as Settings from 'Storage/Settings'; import { AbstractBasicPromises } from 'Promises/AbstractBasic'; @@ -51,7 +50,7 @@ class AbstractAjaxPromises extends AbstractBasicPromises { // 'Content-Type': 'application/json' 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }; - params.XToken = Settings.appSettingsGet('token'); + params.XToken = rl.settings.app('token'); // init.body = JSON.stringify(params); const formData = new FormData(), buildFormData = (formData, data, parentKey) => { @@ -86,8 +85,9 @@ class AbstractAjaxPromises extends AbstractBasicPromises { return Promise.reject(Notification.AjaxParse); } - if (data.UpdateToken && GlobalsData.__APP__ && GlobalsData.__APP__.setClientSideToken) { - GlobalsData.__APP__.setClientSideToken(data.UpdateToken); + if (data.UpdateToken) { + rl.hash.set(); + rl.settings.set('AuthAccountHash', data.UpdateToken); } /* @@ -136,12 +136,12 @@ class AbstractAjaxPromises extends AbstractBasicPromises { } if (data.ClearAuth || data.Logout || AJAX_ERROR_LIMIT < GlobalsData.iAjaxErrorCount) { - if (GlobalsData.__APP__ && GlobalsData.__APP__.clearClientSideToken) { - GlobalsData.__APP__.clearClientSideToken(); - } + if (GlobalsData.__APP__) { + rl.hash.clear(); - if (GlobalsData.__APP__ && !data.ClearAuth && GlobalsData.__APP__.loginAndLogoutReload) { - GlobalsData.__APP__.loginAndLogoutReload(false, true); + if (!data.ClearAuth && GlobalsData.__APP__.loginAndLogoutReload) { + GlobalsData.__APP__.loginAndLogoutReload(false, true); + } } } diff --git a/dev/Promises/User/Populator.js b/dev/Promises/User/Populator.js index fb18a351e..9ee585008 100644 --- a/dev/Promises/User/Populator.js +++ b/dev/Promises/User/Populator.js @@ -3,7 +3,6 @@ import { pInt } from 'Common/Utils'; import { ClientSideKeyName, ServerFolderType } from 'Common/Enums'; import * as Cache from 'Common/Cache'; -import * as Settings from 'Storage/Settings'; import * as Local from 'Storage/Client'; import AppStore from 'Stores/User/App'; @@ -14,6 +13,8 @@ import Remote from 'Remote/User/Ajax'; import { FolderModel } from 'Model/Folder'; import { AbstractBasicPromises } from 'Promises/AbstractBasic'; +const Settings = rl.settings; + class PromisesUserPopulator extends AbstractBasicPromises { /** * @param {string} sFullNameHash @@ -109,7 +110,7 @@ class PromisesUserPopulator extends AbstractBasicPromises { const expandedFolders = Local.get(ClientSideKeyName.ExpandedFolders), cnt = pInt(oData.CountRec); - let limit = pInt(Settings.appSettingsGet('folderSpecLimit')); + let limit = pInt(Settings.app('folderSpecLimit')); limit = 100 < limit ? 100 : 10 > limit ? 10 : limit; FolderStore.displaySpecSetting(0 >= cnt || limit < cnt); @@ -136,7 +137,7 @@ class PromisesUserPopulator extends AbstractBasicPromises { FolderStore.namespace = oData.Namespace; } - AppStore.threadsAllowed(!!Settings.appSettingsGet('useImapThread') && oData.IsThreadsSupported && true); + AppStore.threadsAllowed(!!Settings.app('useImapThread') && oData.IsThreadsSupported && true); FolderStore.folderList.optimized(!!oData.Optimized); @@ -145,27 +146,27 @@ class PromisesUserPopulator extends AbstractBasicPromises { if ( oData.SystemFolders && !('' + - Settings.settingsGet('SentFolder') + - Settings.settingsGet('DraftFolder') + - Settings.settingsGet('SpamFolder') + - Settings.settingsGet('TrashFolder') + - Settings.settingsGet('ArchiveFolder') + - Settings.settingsGet('NullFolder')) + Settings.get('SentFolder') + + Settings.get('DraftFolder') + + Settings.get('SpamFolder') + + Settings.get('TrashFolder') + + Settings.get('ArchiveFolder') + + Settings.get('NullFolder')) ) { - Settings.settingsSet('SentFolder', oData.SystemFolders[ServerFolderType.SENT] || null); - Settings.settingsSet('DraftFolder', oData.SystemFolders[ServerFolderType.DRAFTS] || null); - Settings.settingsSet('SpamFolder', oData.SystemFolders[ServerFolderType.JUNK] || null); - Settings.settingsSet('TrashFolder', oData.SystemFolders[ServerFolderType.TRASH] || null); - Settings.settingsSet('ArchiveFolder', oData.SystemFolders[ServerFolderType.ALL] || null); + Settings.set('SentFolder', oData.SystemFolders[ServerFolderType.SENT] || null); + Settings.set('DraftFolder', oData.SystemFolders[ServerFolderType.DRAFTS] || null); + Settings.set('SpamFolder', oData.SystemFolders[ServerFolderType.JUNK] || null); + Settings.set('TrashFolder', oData.SystemFolders[ServerFolderType.TRASH] || null); + Settings.set('ArchiveFolder', oData.SystemFolders[ServerFolderType.ALL] || null); update = true; } - FolderStore.sentFolder(this.normalizeFolder(Settings.settingsGet('SentFolder'))); - FolderStore.draftFolder(this.normalizeFolder(Settings.settingsGet('DraftFolder'))); - FolderStore.spamFolder(this.normalizeFolder(Settings.settingsGet('SpamFolder'))); - FolderStore.trashFolder(this.normalizeFolder(Settings.settingsGet('TrashFolder'))); - FolderStore.archiveFolder(this.normalizeFolder(Settings.settingsGet('ArchiveFolder'))); + FolderStore.sentFolder(this.normalizeFolder(Settings.get('SentFolder'))); + FolderStore.draftFolder(this.normalizeFolder(Settings.get('DraftFolder'))); + FolderStore.spamFolder(this.normalizeFolder(Settings.get('SpamFolder'))); + FolderStore.trashFolder(this.normalizeFolder(Settings.get('TrashFolder'))); + FolderStore.archiveFolder(this.normalizeFolder(Settings.get('ArchiveFolder'))); if (update) { Remote.saveSystemFolders(()=>{}, { diff --git a/dev/Remote/AbstractAjax.js b/dev/Remote/AbstractAjax.js index e4c0fd019..16ca43ad4 100644 --- a/dev/Remote/AbstractAjax.js +++ b/dev/Remote/AbstractAjax.js @@ -4,7 +4,6 @@ import { pInt, pString } from 'Common/Utils'; import { data as GlobalsData } from 'Common/Globals'; import { ajax } from 'Common/Links'; -import * as Settings from 'Storage/Settings'; class AbstractAjaxRemote { constructor() { @@ -67,8 +66,8 @@ class AbstractAjaxRemote { } if (oData.ClearAuth || oData.Logout || AJAX_ERROR_LIMIT < GlobalsData.iAjaxErrorCount) { - if (GlobalsData.__APP__ && GlobalsData.__APP__.clearClientSideToken) { - GlobalsData.__APP__.clearClientSideToken(); + if (GlobalsData.__APP__) { + rl.hash.clear(); if (!oData.ClearAuth && GlobalsData.__APP__.loginAndLogoutReload) { GlobalsData.__APP__.loginAndLogoutReload(false, true); @@ -140,7 +139,7 @@ class AbstractAjaxRemote { // 'Content-Type': 'application/json' 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }; - params.XToken = Settings.appSettingsGet('token'); + params.XToken = rl.settings.app('token'); // init.body = JSON.stringify(params); const formData = new FormData(), buildFormData = (formData, data, parentKey) => { @@ -175,9 +174,8 @@ class AbstractAjaxRemote { } if (oData && oData.UpdateToken) { - if (GlobalsData.__APP__ && GlobalsData.__APP__.setClientSideToken) { - GlobalsData.__APP__.setClientSideToken(oData.UpdateToken); - } + rl.hash.set(); + rl.settings.set('AuthAccountHash', oData.UpdateToken); } let sType = 'success'; diff --git a/dev/Remote/User/Ajax.js b/dev/Remote/User/Ajax.js index bbbef3642..bb65fbc12 100644 --- a/dev/Remote/User/Ajax.js +++ b/dev/Remote/User/Ajax.js @@ -17,7 +17,6 @@ import { } from 'Common/Cache'; import { subQueryPrefix } from 'Common/Links'; -import * as Settings from 'Storage/Settings'; import AppStore from 'Stores/User/App'; import SettingsStore from 'Stores/User/Settings'; @@ -44,15 +43,16 @@ class RemoteUserAjax extends AbstractAjaxRemote { * @param {?Function} fCallback */ folders(fCallback) { + const settingsGet = rl.settings.get; this.defaultRequest( fCallback, 'Folders', { - SentFolder: Settings.settingsGet('SentFolder'), - DraftFolder: Settings.settingsGet('DraftFolder'), - SpamFolder: Settings.settingsGet('SpamFolder'), - TrashFolder: Settings.settingsGet('TrashFolder'), - ArchiveFolder: Settings.settingsGet('ArchiveFolder') + SentFolder: settingsGet('SentFolder'), + DraftFolder: settingsGet('DraftFolder'), + SpamFolder: settingsGet('SpamFolder'), + TrashFolder: settingsGet('TrashFolder'), + ArchiveFolder: settingsGet('ArchiveFolder') }, null, '', diff --git a/dev/Screen/Admin/Login.js b/dev/Screen/Admin/Login.js index 4e9b6123b..267b17b0f 100644 --- a/dev/Screen/Admin/Login.js +++ b/dev/Screen/Admin/Login.js @@ -1,7 +1,5 @@ import { AbstractScreen } from 'Knoin/AbstractScreen'; -import { getApp } from 'Helper/Apps/Admin'; - import { LoginAdminView } from 'View/Admin/Login'; class LoginAdminScreen extends AbstractScreen { @@ -10,7 +8,7 @@ class LoginAdminScreen extends AbstractScreen { } onShow() { - getApp().setWindowTitle(''); + rl.setWindowTitle(); } } diff --git a/dev/Screen/Admin/Settings.js b/dev/Screen/Admin/Settings.js index 83d30dcec..eaacf8b01 100644 --- a/dev/Screen/Admin/Settings.js +++ b/dev/Screen/Admin/Settings.js @@ -12,8 +12,6 @@ import { PluginsAdminSettings } from 'Settings/Admin/Plugins'; import { PackagesAdminSettings } from 'Settings/Admin/Packages'; import { AboutAdminSettings } from 'Settings/Admin/About'; -import { getApp } from 'Helper/Apps/Admin'; - import { MenuSettingsAdminView } from 'View/Admin/Settings/Menu'; import { PaneSettingsAdminView } from 'View/Admin/Settings/Pane'; @@ -60,7 +58,7 @@ class SettingsAdminScreen extends AbstractSettingsScreen { } onShow() { - getApp().setWindowTitle(''); + rl.setWindowTitle(); } } diff --git a/dev/Screen/User/Login.js b/dev/Screen/User/Login.js index 71599447d..0f5165e7d 100644 --- a/dev/Screen/User/Login.js +++ b/dev/Screen/User/Login.js @@ -2,15 +2,13 @@ import { AbstractScreen } from 'Knoin/AbstractScreen'; import { LoginUserView } from 'View/User/Login'; -import { getApp } from 'Helper/Apps/User'; - class LoginUserScreen extends AbstractScreen { constructor() { super('login', [LoginUserView]); } onShow() { - getApp().setWindowTitle(''); + rl.setWindowTitle(); } } diff --git a/dev/Screen/User/MailBox.js b/dev/Screen/User/MailBox.js index 110a3a47f..077a370f0 100644 --- a/dev/Screen/User/MailBox.js +++ b/dev/Screen/User/MailBox.js @@ -4,8 +4,6 @@ import { pString, pInt } from 'Common/Utils'; import { getFolderFromCacheList, getFolderFullNameRaw, getFolderInboxName } from 'Common/Cache'; import { i18n } from 'Common/Translator'; -import * as Settings from 'Storage/Settings'; - import AppStore from 'Stores/User/App'; import AccountStore from 'Stores/User/Account'; import SettingsStore from 'Stores/User/Settings'; @@ -23,6 +21,8 @@ import { warmUpScreenPopup } from 'Knoin/Knoin'; import { AbstractScreen } from 'Knoin/AbstractScreen'; +const Settings = rl.settings; + class MailBoxUserScreen extends AbstractScreen { constructor() { super('mailbox', [ @@ -40,11 +40,11 @@ class MailBoxUserScreen extends AbstractScreen { let foldersInboxUnreadCount = FolderStore.foldersInboxUnreadCount(); const email = AccountStore.email(); - if (Settings.appSettingsGet('listPermanentFiltered')) { + if (Settings.app('listPermanentFiltered')) { foldersInboxUnreadCount = 0; } - getApp().setWindowTitle( + rl.setWindowTitle( (email ? '' + (0 < foldersInboxUnreadCount ? '(' + foldersInboxUnreadCount + ') ' : ' ') + email + ' - ' : '' @@ -61,7 +61,7 @@ class MailBoxUserScreen extends AbstractScreen { AppStore.focusedState(Focused.None); AppStore.focusedState(Focused.MessageList); - if (Settings.appSettingsGet('mobile')) { + if (Settings.app('mobile')) { leftPanelDisabled(true); } @@ -122,7 +122,7 @@ class MailBoxUserScreen extends AbstractScreen { * @returns {void} */ onBuild() { - if (!bMobileDevice && !Settings.appSettingsGet('mobile')) { + if (!bMobileDevice && !Settings.app('mobile')) { setTimeout(() => getApp().initHorizontalLayoutResizer(ClientSideKeyName.MessageListSize) , 1); diff --git a/dev/Screen/User/Settings.js b/dev/Screen/User/Settings.js index b67d5baf4..265d8525e 100644 --- a/dev/Screen/User/Settings.js +++ b/dev/Screen/User/Settings.js @@ -6,7 +6,6 @@ import { initOnStartOrLangChange, i18n } from 'Common/Translator'; import AppStore from 'Stores/User/App'; import AccountStore from 'Stores/User/Account'; -import * as Settings from 'Storage/Settings'; import { addSettingsViewModel } from 'Knoin/Knoin'; import { AbstractSettingsScreen } from 'Screen/AbstractSettings'; @@ -25,7 +24,7 @@ import { SystemDropDownSettingsUserView } from 'View/User/Settings/SystemDropDow import { MenuSettingsUserView } from 'View/User/Settings/Menu'; import { PaneSettingsUserView } from 'View/User/Settings/Pane'; -import { getApp } from 'Helper/Apps/User'; +const Settings = rl.settings; class SettingsUserScreen extends AbstractSettingsScreen { constructor() { @@ -113,14 +112,14 @@ class SettingsUserScreen extends AbstractSettingsScreen { keyScope(KeyState.Settings); leftPanelType(''); - if (Settings.appSettingsGet('mobile')) { + if (Settings.app('mobile')) { leftPanelDisabled(true); } } setSettingsTitle() { const sEmail = AccountStore.email(); - getApp().setWindowTitle((sEmail ? sEmail + ' - ' : '') + this.sSettingsTitle); + rl.setWindowTitle((sEmail ? sEmail + ' - ' : '') + this.sSettingsTitle); } } diff --git a/dev/Settings/Admin/About.js b/dev/Settings/Admin/About.js index 1cb3e1453..f76ba0f87 100644 --- a/dev/Settings/Admin/About.js +++ b/dev/Settings/Admin/About.js @@ -1,10 +1,8 @@ import ko from 'ko'; -import { appSettingsGet } from 'Storage/Settings'; - class AboutAdminSettings { constructor() { - this.version = ko.observable(appSettingsGet('version')); + this.version = ko.observable(rl.settings.app('version')); this.coreType = ko.observable('djmaze'); } } diff --git a/dev/Settings/Admin/Branding.js b/dev/Settings/Admin/Branding.js index 9e5563bd2..10939d87d 100644 --- a/dev/Settings/Admin/Branding.js +++ b/dev/Settings/Admin/Branding.js @@ -4,10 +4,9 @@ import { settingsSaveHelperSimpleFunction } from 'Common/Utils'; import Remote from 'Remote/Admin/Ajax'; -import { settingsGet } from 'Storage/Settings'; - 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(); diff --git a/dev/Settings/Admin/Contacts.js b/dev/Settings/Admin/Contacts.js index bd43dcfeb..b92c7add0 100644 --- a/dev/Settings/Admin/Contacts.js +++ b/dev/Settings/Admin/Contacts.js @@ -4,10 +4,11 @@ import { settingsSaveHelperSimpleFunction, defautOptionsAfterRender } from 'Comm import { SaveSettingsStep, StorageResultType } from 'Common/Enums'; import { i18n } from 'Common/Translator'; -import { settingsGet } from 'Storage/Settings'; import Remote from 'Remote/Admin/Ajax'; import { command } from 'Knoin/Knoin'; +const settingsGet = rl.settings.get; + class ContactsAdminSettings { constructor() { this.defautOptionsAfterRender = defautOptionsAfterRender; diff --git a/dev/Settings/Admin/General.js b/dev/Settings/Admin/General.js index 94062650d..f92660b50 100644 --- a/dev/Settings/Admin/General.js +++ b/dev/Settings/Admin/General.js @@ -11,7 +11,6 @@ import { import { SaveSettingsStep } from 'Common/Enums'; import { reload as translatorReload } from 'Common/Translator'; -import { settingsGet } from 'Storage/Settings'; import { showScreenPopup } from 'Knoin/Knoin'; import Remote from 'Remote/Admin/Ajax'; @@ -21,6 +20,8 @@ import LanguageStore from 'Stores/Language'; import AppAdminStore from 'Stores/Admin/App'; import CapaAdminStore from 'Stores/Admin/Capa'; +const settingsGet = rl.settings.get; + class GeneralAdminSettings { constructor() { this.language = LanguageStore.language; diff --git a/dev/Settings/Admin/Login.js b/dev/Settings/Admin/Login.js index f200d83b2..dce70138f 100644 --- a/dev/Settings/Admin/Login.js +++ b/dev/Settings/Admin/Login.js @@ -1,7 +1,6 @@ import ko from 'ko'; import { settingsSaveHelperSimpleFunction } from 'Common/Utils'; -import { settingsGet } from 'Storage/Settings'; import AppStore from 'Stores/Admin/App'; @@ -12,7 +11,7 @@ class LoginAdminSettings { this.determineUserLanguage = AppStore.determineUserLanguage; this.determineUserDomain = AppStore.determineUserDomain; - this.defaultDomain = ko.observable(settingsGet('LoginDefaultDomain')).idleTrigger(); + this.defaultDomain = ko.observable(rl.settings.get('LoginDefaultDomain')).idleTrigger(); this.allowLanguagesOnLogin = AppStore.allowLanguagesOnLogin; this.dummy = ko.observable(false); diff --git a/dev/Settings/Admin/Plugins.js b/dev/Settings/Admin/Plugins.js index a32d640cd..f39ce03e0 100644 --- a/dev/Settings/Admin/Plugins.js +++ b/dev/Settings/Admin/Plugins.js @@ -3,7 +3,6 @@ import ko from 'ko'; import { StorageResultType, Notification } from 'Common/Enums'; import { getNotification } from 'Common/Translator'; -import { settingsGet } from 'Storage/Settings'; import { showScreenPopup } from 'Knoin/Knoin'; import PluginStore from 'Stores/Admin/Plugin'; @@ -14,7 +13,7 @@ import { getApp } from 'Helper/Apps/Admin'; class PluginsAdminSettings { constructor() { - this.enabledPlugins = ko.observable(!!settingsGet('EnabledPlugins')); + this.enabledPlugins = ko.observable(!!rl.settings.get('EnabledPlugins')); this.plugins = PluginStore.plugins; this.pluginsError = PluginStore.plugins.error; diff --git a/dev/Settings/Admin/Security.js b/dev/Settings/Admin/Security.js index f752c9820..2c10f14a6 100644 --- a/dev/Settings/Admin/Security.js +++ b/dev/Settings/Admin/Security.js @@ -2,8 +2,6 @@ import ko from 'ko'; import { StorageResultType } from 'Common/Enums'; -import { settingsGet } from 'Storage/Settings'; - import AppAdminStore from 'Stores/Admin/App'; import CapaAdminStore from 'Stores/Admin/Capa'; @@ -11,6 +9,8 @@ import Remote from 'Remote/Admin/Ajax'; import { command } from 'Knoin/Knoin'; +const settingsGet = rl.settings.get; + class SecurityAdminSettings { constructor() { this.useLocalProxyForExternalImages = AppAdminStore.useLocalProxyForExternalImages; diff --git a/dev/Settings/User/Accounts.js b/dev/Settings/User/Accounts.js index 05570e5be..f2399c391 100644 --- a/dev/Settings/User/Accounts.js +++ b/dev/Settings/User/Accounts.js @@ -3,8 +3,6 @@ import ko from 'ko'; import { Capa, StorageResultType } from 'Common/Enums'; import { root } from 'Common/Links'; -import { capa } from 'Storage/Settings'; - import AccountStore from 'Stores/User/Account'; import IdentityStore from 'Stores/User/Identity'; import Remote from 'Remote/User/Ajax'; @@ -15,8 +13,8 @@ import { showScreenPopup, routeOff, setHash } from 'Knoin/Knoin'; class AccountsUserSettings { constructor() { - this.allowAdditionalAccount = capa(Capa.AdditionalAccounts); - this.allowIdentities = capa(Capa.Identities); + this.allowAdditionalAccount = rl.settings.capa(Capa.AdditionalAccounts); + this.allowIdentities = rl.settings.capa(Capa.Identities); this.accounts = AccountStore.accounts; this.identities = IdentityStore.identities; diff --git a/dev/Settings/User/Folders.js b/dev/Settings/User/Folders.js index 7d955c958..52e650046 100644 --- a/dev/Settings/User/Folders.js +++ b/dev/Settings/User/Folders.js @@ -5,7 +5,6 @@ import { getNotification, i18n } from 'Common/Translator'; import { removeFolderFromCacheList } from 'Common/Cache'; -import { appSettingsGet } from 'Storage/Settings'; import * as Local from 'Storage/Client'; import FolderStore from 'Stores/User/Folder'; @@ -37,7 +36,7 @@ class FoldersUserSettings { this.folderForEdit = ko.observable(null).extend({ toggleSubscribeProperty: [this, 'edited'] }); - this.useImapSubscribe = !!appSettingsGet('useImapSubscribe'); + this.useImapSubscribe = !!rl.settings.app('useImapSubscribe'); } folderEditOnEnter(folder) { diff --git a/dev/Settings/User/Security.js b/dev/Settings/User/Security.js index 1a8bdc638..731744b30 100644 --- a/dev/Settings/User/Security.js +++ b/dev/Settings/User/Security.js @@ -4,8 +4,6 @@ import { pInt, settingsSaveHelperSimpleFunction } from 'Common/Utils'; import { Capa, SaveSettingsStep } from 'Common/Enums'; import { i18n, trigger as translatorTrigger } from 'Common/Translator'; -import { capa } from 'Storage/Settings'; - import { showScreenPopup } from 'Knoin/Knoin'; import SettinsStore from 'Stores/User/Settings'; @@ -14,8 +12,8 @@ import Remote from 'Remote/User/Ajax'; class SecurityUserSettings { constructor() { - this.capaAutoLogout = capa(Capa.AutoLogout); - this.capaTwoFactor = capa(Capa.TwoFactor); + this.capaAutoLogout = rl.settings.capa(Capa.AutoLogout); + this.capaTwoFactor = rl.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 01beb9285..37370b3b6 100644 --- a/dev/Settings/User/Themes.js +++ b/dev/Settings/User/Themes.js @@ -5,8 +5,6 @@ import { changeTheme, convertThemeName } from 'Common/Utils'; import { userBackground, themePreviewLink, uploadBackground } from 'Common/Links'; import { i18n } from 'Common/Translator'; -import { capa } from 'Storage/Settings'; - import ThemeStore from 'Stores/Theme'; import Remote from 'Remote/User/Ajax'; @@ -24,7 +22,7 @@ class ThemesUserSettings { this.background.loading = ko.observable(false); this.background.error = ko.observable(''); - this.capaUserBackground = ko.observable(capa(Capa.UserBackground)); + this.capaUserBackground = ko.observable(rl.settings.capa(Capa.UserBackground)); this.themeTrigger = ko.observable(SaveSettingsStep.Idle).extend({ throttle: 100 }); diff --git a/dev/Storage/Settings.js b/dev/Storage/Settings.js deleted file mode 100644 index 19ece021f..000000000 --- a/dev/Storage/Settings.js +++ /dev/null @@ -1,36 +0,0 @@ -let SETTINGS = RainLoop.data() || null; -SETTINGS = null != SETTINGS ? SETTINGS : {}; - -/** - * @param {string} name - * @returns {*} - */ -export function settingsGet(name) { - return null == SETTINGS[name] ? null : SETTINGS[name]; -} - -/** - * @param {string} name - * @param {*} value - */ -export function settingsSet(name, value) { - SETTINGS[name] = value; -} - -/** - * @param {string} name - * @returns {*} - */ -export function appSettingsGet(name) { - const APP_SETTINGS = SETTINGS.System || {}; - return null == APP_SETTINGS[name] ? null : APP_SETTINGS[name]; -} - -/** - * @param {string} name - * @returns {boolean} - */ -export function capa(name) { - const values = SETTINGS.Capa; - return Array.isArray(values) && null != name && values.includes(name); -} diff --git a/dev/Stores/AbstractApp.js b/dev/Stores/AbstractApp.js index eebc47c39..db3131be1 100644 --- a/dev/Stores/AbstractApp.js +++ b/dev/Stores/AbstractApp.js @@ -1,5 +1,4 @@ import ko from 'ko'; -import * as Settings from 'Storage/Settings'; class AbstractAppStore { constructor() { @@ -9,9 +8,9 @@ class AbstractAppStore { } populate() { - this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin')); - this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings')); - this.newMoveToFolder(!!Settings.settingsGet('NewMoveToFolder')); + this.allowLanguagesOnLogin(!!rl.settings.get('AllowLanguagesOnLogin')); + this.allowLanguagesOnSettings(!!rl.settings.get('AllowLanguagesOnSettings')); + this.newMoveToFolder(!!rl.settings.get('NewMoveToFolder')); } } diff --git a/dev/Stores/Admin/App.js b/dev/Stores/Admin/App.js index 7933f1e93..6fc4ecca7 100644 --- a/dev/Stores/Admin/App.js +++ b/dev/Stores/Admin/App.js @@ -1,5 +1,4 @@ import ko from 'ko'; -import { settingsGet } from 'Storage/Settings'; import { AbstractAppStore } from 'Stores/AbstractApp'; class AppAdminStore extends AbstractAppStore { @@ -18,6 +17,7 @@ class AppAdminStore extends AbstractAppStore { populate() { super.populate(); + const settingsGet = rl.settings this.determineUserLanguage(!!settingsGet('DetermineUserLanguage')); this.determineUserDomain(!!settingsGet('DetermineUserDomain')); diff --git a/dev/Stores/Admin/Capa.js b/dev/Stores/Admin/Capa.js index daadebea8..7202daec4 100644 --- a/dev/Stores/Admin/Capa.js +++ b/dev/Stores/Admin/Capa.js @@ -1,6 +1,5 @@ import ko from 'ko'; import { Capa } from 'Common/Enums'; -import * as Settings from 'Storage/Settings'; class CapaAdminStore { constructor() { @@ -18,17 +17,18 @@ class CapaAdminStore { } populate() { - this.additionalAccounts(Settings.capa(Capa.AdditionalAccounts)); - this.identities(Settings.capa(Capa.Identities)); - this.attachmentThumbnails(Settings.capa(Capa.AttachmentThumbnails)); - this.sieve(Settings.capa(Capa.Sieve)); - this.filters(Settings.capa(Capa.Filters)); - this.themes(Settings.capa(Capa.Themes)); - this.userBackground(Settings.capa(Capa.UserBackground)); - this.openPGP(Settings.capa(Capa.OpenPGP)); - this.twoFactorAuth(Settings.capa(Capa.TwoFactor)); - this.twoFactorAuthForce(Settings.capa(Capa.TwoFactorForce)); - this.templates(Settings.capa(Capa.Templates)); + let capa = rl.settings.capa; + this.additionalAccounts(capa(Capa.AdditionalAccounts)); + this.identities(capa(Capa.Identities)); + this.attachmentThumbnails(capa(Capa.AttachmentThumbnails)); + this.sieve(capa(Capa.Sieve)); + this.filters(capa(Capa.Filters)); + this.themes(capa(Capa.Themes)); + this.userBackground(capa(Capa.UserBackground)); + this.openPGP(capa(Capa.OpenPGP)); + this.twoFactorAuth(capa(Capa.TwoFactor)); + this.twoFactorAuthForce(capa(Capa.TwoFactorForce)); + this.templates(capa(Capa.Templates)); } } diff --git a/dev/Stores/Language.js b/dev/Stores/Language.js index 1430ce342..eedd46da3 100644 --- a/dev/Stores/Language.js +++ b/dev/Stores/Language.js @@ -1,5 +1,4 @@ import ko from 'ko'; -import * as Settings from 'Storage/Settings'; class LanguageStore { constructor() { @@ -21,17 +20,18 @@ class LanguageStore { } populate() { - const aLanguages = Settings.appSettingsGet('languages'), - aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin'); + const Settings = rl.settings, + aLanguages = Settings.app('languages'), + aLanguagesAdmin = Settings.app('languagesAdmin'); this.languages(Array.isArray(aLanguages) ? aLanguages : []); this.languagesAdmin(Array.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []); - this.language(Settings.settingsGet('Language')); - this.languageAdmin(Settings.settingsGet('LanguageAdmin')); + this.language(Settings.get('Language')); + this.languageAdmin(Settings.get('LanguageAdmin')); - this.userLanguage(Settings.settingsGet('UserLanguage')); - this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin')); + this.userLanguage(Settings.get('UserLanguage')); + this.userLanguageAdmin(Settings.get('UserLanguageAdmin')); } } diff --git a/dev/Stores/Theme.js b/dev/Stores/Theme.js index 3dc346e4b..9a7d441e1 100644 --- a/dev/Stores/Theme.js +++ b/dev/Stores/Theme.js @@ -1,5 +1,4 @@ import ko from 'ko'; -import * as Settings from 'Storage/Settings'; class ThemeStore { constructor() { @@ -11,12 +10,13 @@ class ThemeStore { } populate() { - const themes = Settings.appSettingsGet('themes'); + const Settings = rl.settings, + themes = Settings.app('themes'); this.themes(Array.isArray(themes) ? themes : []); - this.theme(Settings.settingsGet('Theme')); - this.themeBackgroundName(Settings.settingsGet('UserBackgroundName')); - this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash')); + this.theme(Settings.get('Theme')); + this.themeBackgroundName(Settings.get('UserBackgroundName')); + this.themeBackgroundHash(Settings.get('UserBackgroundHash')); } } diff --git a/dev/Stores/User/Account.js b/dev/Stores/User/Account.js index a6b789ac7..2fa866680 100644 --- a/dev/Stores/User/Account.js +++ b/dev/Stores/User/Account.js @@ -1,5 +1,4 @@ import ko from 'ko'; -import * as Settings from 'Storage/Settings'; class AccountUserStore { constructor() { @@ -33,8 +32,8 @@ class AccountUserStore { } populate() { - this.email(Settings.settingsGet('Email')); - this.parentEmail(Settings.settingsGet('ParentEmail')); + this.email(rl.settings.get('Email')); + this.parentEmail(rl.settings.get('ParentEmail')); } /** diff --git a/dev/Stores/User/App.js b/dev/Stores/User/App.js index 67ab37cdb..e92e35d40 100644 --- a/dev/Stores/User/App.js +++ b/dev/Stores/User/App.js @@ -4,10 +4,10 @@ import { Focused, KeyState } from 'Common/Enums'; import { keyScope, leftPanelDisabled } from 'Common/Globals'; import { isNonEmptyArray } from 'Common/Utils'; -import * as Settings from 'Storage/Settings'; - import { AbstractAppStore } from 'Stores/AbstractApp'; +const Settings = rl.settings; + class AppUserStore extends AbstractAppStore { constructor() { super(); @@ -16,7 +16,7 @@ class AppUserStore extends AbstractAppStore { this.focusedState = ko.observable(Focused.None); - const isMobile = Settings.appSettingsGet('mobile'); + const isMobile = Settings.app('mobile'); this.focusedState.subscribe((value) => { switch (value) { @@ -62,18 +62,18 @@ class AppUserStore extends AbstractAppStore { populate() { super.populate(); - this.projectHash(Settings.settingsGet('ProjectHash')); + this.projectHash(Settings.get('ProjectHash')); - this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave')); - this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages')); + this.contactsAutosave(!!Settings.get('ContactsAutosave')); + this.useLocalProxyForExternalImages(!!Settings.get('UseLocalProxyForExternalImages')); - this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed')); + this.contactsIsAllowed(!!Settings.get('ContactsIsAllowed')); - const attachmentsActions = Settings.appSettingsGet('attachmentsActions'); + const attachmentsActions = Settings.app('attachmentsActions'); this.attachmentsActions(isNonEmptyArray(attachmentsActions) ? attachmentsActions : []); - this.devEmail = Settings.settingsGet('DevEmail'); - this.devPassword = Settings.settingsGet('DevPassword'); + this.devEmail = Settings.get('DevEmail'); + this.devPassword = Settings.get('DevPassword'); } } diff --git a/dev/Stores/User/Contact.js b/dev/Stores/User/Contact.js index 9d85b00fc..93fefcba8 100644 --- a/dev/Stores/User/Contact.js +++ b/dev/Stores/User/Contact.js @@ -1,5 +1,4 @@ import ko from 'ko'; -import * as Settings from 'Storage/Settings'; class ContactUserStore { constructor() { @@ -18,12 +17,13 @@ class ContactUserStore { } populate() { - this.allowContactsSync(!!Settings.settingsGet('ContactsSyncIsAllowed')); - this.enableContactsSync(!!Settings.settingsGet('EnableContactsSync')); + const settingsGet = rl.settings.get; + this.allowContactsSync(!!settingsGet('ContactsSyncIsAllowed')); + this.enableContactsSync(!!settingsGet('EnableContactsSync')); - this.contactsSyncUrl(Settings.settingsGet('ContactsSyncUrl')); - this.contactsSyncUser(Settings.settingsGet('ContactsSyncUser')); - this.contactsSyncPass(Settings.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 2c2a2fafc..dbccc594f 100644 --- a/dev/Stores/User/Folder.js +++ b/dev/Stores/User/Folder.js @@ -1,7 +1,5 @@ import ko from 'ko'; -import { settingsGet } from 'Storage/Settings'; - import { FolderType } from 'Common/Enums'; import { UNUSED_OPTION_VALUE } from 'Common/Consts'; import { folderListOptionsBuilder } from 'Common/Utils'; @@ -32,7 +30,7 @@ class FolderUserStore { this.currentFolder = ko.observable(null).extend({ toggleSubscribeProperty: [this, 'selected'] }); - this.sieveAllowFileintoInbox = !!settingsGet('SieveAllowFileintoInbox'); + this.sieveAllowFileintoInbox = !!rl.settings.get('SieveAllowFileintoInbox'); this.computers(); this.subscribers(); diff --git a/dev/Stores/User/Notification.js b/dev/Stores/User/Notification.js index 0f8be5657..8a7154f3b 100644 --- a/dev/Stores/User/Notification.js +++ b/dev/Stores/User/Notification.js @@ -3,7 +3,6 @@ import ko from 'ko'; import { DesktopNotification } from 'Common/Enums'; import Audio from 'Common/Audio'; -import * as Settings from 'Storage/Settings'; class NotificationUserStore { constructor() { @@ -159,8 +158,8 @@ class NotificationUserStore { } populate() { - this.enableSoundNotification(!!Settings.settingsGet('SoundNotification')); - this.enableDesktopNotification(!!Settings.settingsGet('DesktopNotifications')); + this.enableSoundNotification(!!rl.settings.get('SoundNotification')); + this.enableDesktopNotification(!!rl.settings.get('DesktopNotifications')); } /** diff --git a/dev/Stores/User/Settings.js b/dev/Stores/User/Settings.js index 2115d62ee..7ffe2fe10 100644 --- a/dev/Stores/User/Settings.js +++ b/dev/Stores/User/Settings.js @@ -4,8 +4,6 @@ import { MESSAGES_PER_PAGE, MESSAGES_PER_PAGE_VALUES } from 'Common/Consts'; import { Layout, EditorDefaultType } from 'Common/Enums'; import { pInt } from 'Common/Utils'; -import * as Settings from 'Storage/Settings'; - class SettingsUserStore { constructor() { this.iAutoLogoutTimer = 0; @@ -52,21 +50,22 @@ class SettingsUserStore { } populate() { - this.layout(pInt(Settings.settingsGet('Layout'))); - this.editorDefaultType(Settings.settingsGet('EditorDefaultType')); + const settingsGet = rl.settings.get; + this.layout(pInt(settingsGet('Layout'))); + this.editorDefaultType(settingsGet('EditorDefaultType')); - this.autoLogout(pInt(Settings.settingsGet('AutoLogout'))); - this.messagesPerPage(Settings.settingsGet('MPP')); + this.autoLogout(pInt(settingsGet('AutoLogout'))); + this.messagesPerPage(settingsGet('MPP')); - this.showImages(!!Settings.settingsGet('ShowImages')); - this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList')); - this.allowDraftAutosave(!!Settings.settingsGet('AllowDraftAutosave')); - this.useThreads(!!Settings.settingsGet('UseThreads')); - this.replySameFolder(!!Settings.settingsGet('ReplySameFolder')); + this.showImages(!!settingsGet('ShowImages')); + this.useCheckboxesInList(!!settingsGet('UseCheckboxesInList')); + this.allowDraftAutosave(!!settingsGet('AllowDraftAutosave')); + this.useThreads(!!settingsGet('UseThreads')); + this.replySameFolder(!!settingsGet('ReplySameFolder')); const refresh = () => { clearTimeout(this.iAutoLogoutTimer); - if (0 < this.autoLogout() && !Settings.settingsGet('AccountSignMe')) { + if (0 < this.autoLogout() && !settingsGet('AccountSignMe')) { this.iAutoLogoutTimer = setTimeout(() => dispatchEvent(new CustomEvent('rl.auto-logout')) , this.autoLogout() * 60000); diff --git a/dev/View/Admin/Login.js b/dev/View/Admin/Login.js index edfe398d2..07b4ff5e4 100644 --- a/dev/View/Admin/Login.js +++ b/dev/View/Admin/Login.js @@ -3,8 +3,6 @@ import ko from 'ko'; import { StorageResultType, Notification } from 'Common/Enums'; import { getNotification } from 'Common/Translator'; -import * as Settings from 'Storage/Settings'; - import Remote from 'Remote/Admin/Ajax'; import { getApp } from 'Helper/Apps/Admin'; @@ -21,10 +19,11 @@ class LoginAdminView extends AbstractViewNext { constructor() { super(); - this.mobile = !!Settings.appSettingsGet('mobile'); - this.mobileDevice = !!Settings.appSettingsGet('mobileDevice'); + const appSettingsGet = rl.settings.app; + this.mobile = !!appSettingsGet('mobile'); + this.mobileDevice = !!appSettingsGet('mobileDevice'); - this.hideSubmitButton = Settings.appSettingsGet('hideSubmitButton') ? '' : null; + this.hideSubmitButton = appSettingsGet('hideSubmitButton') ? '' : null; this.login = ko.observable(''); this.password = ko.observable(''); diff --git a/dev/View/Admin/Settings/Pane.js b/dev/View/Admin/Settings/Pane.js index 4c7a65f7f..de087ef96 100644 --- a/dev/View/Admin/Settings/Pane.js +++ b/dev/View/Admin/Settings/Pane.js @@ -1,7 +1,5 @@ import ko from 'ko'; -import * as Settings from 'Storage/Settings'; - import Remote from 'Remote/Admin/Ajax'; import DomainStore from 'Stores/Admin/Domain'; @@ -22,7 +20,7 @@ class PaneSettingsAdminView extends AbstractViewNext { constructor() { super(); - this.version = ko.observable(Settings.appSettingsGet('version')); + this.version = ko.observable(rl.settings.app('version')); this.adminManLoading = ko.computed( () => diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index a02cf62e6..d5ba7ac86 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -39,8 +39,6 @@ import MessageStore from 'Stores/User/Message'; import Remote from 'Remote/User/Ajax'; -import * as Settings from 'Storage/Settings'; - import { ComposeAttachmentModel } from 'Model/ComposeAttachment'; import { getApp } from 'Helper/Apps/User'; @@ -48,6 +46,8 @@ import { getApp } from 'Helper/Apps/User'; import { popup, command, isPopupVisible, showScreenPopup, hideScreenPopup, routeOn, routeOff } from 'Knoin/Knoin'; import { AbstractViewNext } from 'Knoin/AbstractViewNext'; +const Settings = rl.settings; + @popup({ name: 'View/Popup/Compose', templateID: 'PopupsCompose' @@ -1138,7 +1138,7 @@ class ComposePopupView extends AbstractViewNext { }); } - if (Settings.appSettingsGet('allowCtrlEnterOnCompose')) { + if (Settings.app('allowCtrlEnterOnCompose')) { key('ctrl+enter, command+enter', KeyState.Compose, () => { this.sendCommand(); return false; @@ -1184,7 +1184,7 @@ class ComposePopupView extends AbstractViewNext { initUploader() { if (this.composeUploaderButton()) { const uploadCache = {}, - attachmentSizeLimit = pInt(Settings.settingsGet('AttachmentLimit')), + attachmentSizeLimit = pInt(Settings.get('AttachmentLimit')), oJua = new Jua({ action: upload(), name: 'uploader', diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index b44faeb95..607504b7f 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -30,8 +30,6 @@ import ContactStore from 'Stores/User/Contact'; import Remote from 'Remote/User/Ajax'; -import * as Settings from 'Storage/Settings'; - import { EmailModel } from 'Model/Email'; import { ContactModel } from 'Model/Contact'; import { ContactPropertyModel } from 'Model/ContactProperty'; @@ -221,7 +219,7 @@ class ContactsPopupView extends AbstractViewNext { @command((self) => 0 < self.contactsCheckedOrSelected().length) newMessageCommand() { - if (!Settings.capa(Capa.Composer)) { + if (!rl.settings.capa(Capa.Composer)) { return false; } @@ -658,7 +656,7 @@ class ContactsPopupView extends AbstractViewNext { if (this.bBackToCompose) { this.bBackToCompose = false; - if (Settings.capa(Capa.Composer)) { + if (rl.settings.capa(Capa.Composer)) { showScreenPopup(require('View/Popup/Compose')); } } diff --git a/dev/View/Popup/FolderSystem.js b/dev/View/Popup/FolderSystem.js index 9770b36b3..70cee1212 100644 --- a/dev/View/Popup/FolderSystem.js +++ b/dev/View/Popup/FolderSystem.js @@ -7,7 +7,6 @@ import { initOnStartOrLangChange, i18n } from 'Common/Translator'; import FolderStore from 'Stores/User/Folder'; -import * as Settings from 'Storage/Settings'; import Remote from 'Remote/User/Ajax'; import { popup } from 'Knoin/Knoin'; @@ -55,12 +54,13 @@ class FolderSystemPopupView extends AbstractViewNext { this.trashFolder = FolderStore.trashFolder; this.archiveFolder = FolderStore.archiveFolder; - const fSetSystemFolders = () => { - Settings.settingsSet('SentFolder', FolderStore.sentFolder()); - Settings.settingsSet('DraftFolder', FolderStore.draftFolder()); - Settings.settingsSet('SpamFolder', FolderStore.spamFolder()); - Settings.settingsSet('TrashFolder', FolderStore.trashFolder()); - Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder()); + const settingsSet = rl.settings.set, + fSetSystemFolders = () => { + settingsSet('SentFolder', FolderStore.sentFolder()); + settingsSet('DraftFolder', FolderStore.draftFolder()); + settingsSet('SpamFolder', FolderStore.spamFolder()); + settingsSet('TrashFolder', FolderStore.trashFolder()); + settingsSet('ArchiveFolder', FolderStore.archiveFolder()); }, fSaveSystemFolders = (()=>{ fSetSystemFolders(); diff --git a/dev/View/Popup/TwoFactorConfiguration.js b/dev/View/Popup/TwoFactorConfiguration.js index 3db84b3fc..b648ca366 100644 --- a/dev/View/Popup/TwoFactorConfiguration.js +++ b/dev/View/Popup/TwoFactorConfiguration.js @@ -4,8 +4,6 @@ import { Capa, StorageResultType } from 'Common/Enums'; import { pString } from 'Common/Utils'; import { i18n, trigger as translatorTrigger } from 'Common/Translator'; -import * as Settings from 'Storage/Settings'; - import Remote from 'Remote/User/Ajax'; import { getApp } from 'Helper/Apps/User'; @@ -23,7 +21,7 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext { this.lock = ko.observable(false); - this.capaTwoFactor = Settings.capa(Capa.TwoFactor); + this.capaTwoFactor = rl.settings.capa(Capa.TwoFactor); this.processing = ko.observable(false); this.clearing = ko.observable(false); diff --git a/dev/View/User/AbstractSystemDropDown.js b/dev/View/User/AbstractSystemDropDown.js index 49df6d165..8448aba50 100644 --- a/dev/View/User/AbstractSystemDropDown.js +++ b/dev/View/User/AbstractSystemDropDown.js @@ -7,22 +7,23 @@ import MessageStore from 'Stores/User/Message'; import { Capa, KeyState } from 'Common/Enums'; import { settings } from 'Common/Links'; -import * as Settings from 'Storage/Settings'; import { getApp } from 'Helper/Apps/User'; import { showScreenPopup, setHash } from 'Knoin/Knoin'; import { AbstractViewNext } from 'Knoin/AbstractViewNext'; +const Settings = rl.settings; + class AbstractSystemDropDownUserView extends AbstractViewNext { constructor() { super(); - this.logoImg = (Settings.settingsGet('UserLogo')||'').trim(); - this.logoTitle = (Settings.settingsGet('UserLogoTitle')||'').trim(); + this.logoImg = (Settings.get('UserLogo')||'').trim(); + this.logoTitle = (Settings.get('UserLogoTitle')||'').trim(); - this.mobile = !!Settings.appSettingsGet('mobile'); - this.mobileDevice = !!Settings.appSettingsGet('mobileDevice'); + this.mobile = !!Settings.app('mobile'); + this.mobileDevice = !!Settings.app('mobileDevice'); this.allowSettings = !!Settings.capa(Capa.Settings); this.allowHelp = !!Settings.capa(Capa.Help); diff --git a/dev/View/User/Login.js b/dev/View/User/Login.js index adb07c5a8..e7faead5a 100644 --- a/dev/View/User/Login.js +++ b/dev/View/User/Login.js @@ -15,7 +15,6 @@ import { getNotification, getNotificationFromResponse, reload as translatorReloa import AppStore from 'Stores/User/App'; import LanguageStore from 'Stores/Language'; -import * as Settings from 'Storage/Settings'; import * as Local from 'Storage/Client'; import Remote from 'Remote/User/Ajax'; @@ -25,6 +24,8 @@ import { getApp } from 'Helper/Apps/User'; import { view, command, ViewType, routeOff, showScreenPopup } from 'Knoin/Knoin'; import { AbstractViewNext } from 'Knoin/AbstractViewNext'; +const Settings = rl.settings; + @view({ name: ['View/App/Login', 'View/User/Login'], type: ViewType.Center, @@ -34,9 +35,9 @@ class LoginUserView extends AbstractViewNext { constructor() { super(); - this.hideSubmitButton = Settings.appSettingsGet('hideSubmitButton') ? '' : null; + this.hideSubmitButton = Settings.app('hideSubmitButton') ? '' : null; - this.welcome = ko.observable(!!Settings.settingsGet('UseLoginWelcomePage')); + this.welcome = ko.observable(!!Settings.get('UseLoginWelcomePage')); this.email = ko.observable(''); this.password = ko.observable(''); @@ -48,14 +49,14 @@ class LoginUserView extends AbstractViewNext { this.additionalCode.visibility = ko.observable(false); this.additionalCodeSignMe = ko.observable(false); - this.logoImg = (Settings.settingsGet('LoginLogo')||'').trim(); - this.loginDescription = (Settings.settingsGet('LoginDescription')||'').trim(); + this.logoImg = (Settings.get('LoginLogo')||'').trim(); + this.loginDescription = (Settings.get('LoginDescription')||'').trim(); - this.mobile = !!Settings.appSettingsGet('mobile'); - this.mobileDevice = !!Settings.appSettingsGet('mobileDevice'); + this.mobile = !!Settings.app('mobile'); + this.mobileDevice = !!Settings.app('mobileDevice'); - this.forgotPasswordLinkUrl = Settings.appSettingsGet('forgotPasswordLinkUrl'); - this.registrationLinkUrl = Settings.appSettingsGet('registrationLinkUrl'); + this.forgotPasswordLinkUrl = Settings.app('forgotPasswordLinkUrl'); + this.registrationLinkUrl = Settings.app('registrationLinkUrl'); this.emailError = ko.observable(false); this.passwordError = ko.observable(false); @@ -130,8 +131,8 @@ class LoginUserView extends AbstractViewNext { this.signMeVisibility = ko.computed(() => LoginSignMeType.Unused !== this.signMeType()); - if (Settings.settingsGet('AdditionalLoginError') && !this.submitError()) { - this.submitError(Settings.settingsGet('AdditionalLoginError')); + if (Settings.get('AdditionalLoginError') && !this.submitError()) { + this.submitError(Settings.get('AdditionalLoginError')); } } @@ -231,7 +232,7 @@ class LoginUserView extends AbstractViewNext { onBuild() { const signMeLocal = Local.get(ClientSideKeyName.LastSignMe), - signMe = (Settings.settingsGet('SignMe') || 'unused').toLowerCase(); + signMe = (Settings.get('SignMe') || 'unused').toLowerCase(); switch (signMe) { case LoginSignMeTypeAsString.DefaultOff: diff --git a/dev/View/User/MailBox/FolderList.js b/dev/View/User/MailBox/FolderList.js index 44d00f0c8..b7dfcc566 100644 --- a/dev/View/User/MailBox/FolderList.js +++ b/dev/View/User/MailBox/FolderList.js @@ -10,13 +10,13 @@ import SettingsStore from 'Stores/User/Settings'; import FolderStore from 'Stores/User/Folder'; import MessageStore from 'Stores/User/Message'; -import * as Settings from 'Storage/Settings'; - import { getApp } from 'Helper/Apps/User'; import { view, ViewType, showScreenPopup, setHash } from 'Knoin/Knoin'; import { AbstractViewNext } from 'Knoin/AbstractViewNext'; +const Settings = rl.settings; + @view({ name: 'View/User/MailBox/FolderList', type: ViewType.Left, @@ -60,7 +60,7 @@ class FolderListMailBoxUserView extends AbstractViewNext { onBuild(dom) { const qs = s => dom.querySelector(s), eqs = (ev, s) => ev.target.closestWithin(s, dom), - isMobile = Settings.appSettingsGet('mobile'), + isMobile = Settings.app('mobile'), fSelectFolder = (el, event, starred) => { const isMove = moveAction(); if (isMobile) { diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 8a3e151e0..8b359a3a0 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -35,7 +35,6 @@ import SettingsStore from 'Stores/User/Settings'; import FolderStore from 'Stores/User/Folder'; import MessageStore from 'Stores/User/Message'; -import * as Settings from 'Storage/Settings'; import Remote from 'Remote/User/Ajax'; import { getApp } from 'Helper/Apps/User'; @@ -44,6 +43,7 @@ import { view, command, ViewType, showScreenPopup, setHash, popupVisibility } fr import { AbstractViewNext } from 'Knoin/AbstractViewNext'; const + Settings = rl.settings, canBeMovedHelper = (self) => self.canBeMoved(), ifvisible = window.ifvisible; @@ -62,7 +62,7 @@ class MessageListMailBoxUserView extends AbstractViewNext { this.iGoToUpUpOrDownDownTimeout = 0; - this.mobile = !!Settings.appSettingsGet('mobile'); + this.mobile = !!Settings.app('mobile'); this.newMoveToFolder = AppStore.newMoveToFolder; this.allowReload = !!Settings.capa(Capa.Reload); @@ -944,7 +944,7 @@ class MessageListMailBoxUserView extends AbstractViewNext { } initUploaderForAppend() { - if (!Settings.appSettingsGet('allowAppendMessage') || !this.dragOverArea()) { + if (!Settings.app('allowAppendMessage') || !this.dragOverArea()) { return false; } diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index af850d5ec..5b9f41883 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -38,7 +38,6 @@ import FolderStore from 'Stores/User/Folder'; import MessageStore from 'Stores/User/Message'; import * as Local from 'Storage/Client'; -import * as Settings from 'Storage/Settings'; import Remote from 'Remote/User/Ajax'; import Promises from 'Promises/User/Ajax'; @@ -48,6 +47,8 @@ import { getApp } from 'Helper/Apps/User'; import { view, command, ViewType, showScreenPopup, createCommand } from 'Knoin/Knoin'; import { AbstractViewNext } from 'Knoin/AbstractViewNext'; +const Settings = rl.settings; + @view({ name: 'View/User/MailBox/MessageView', type: ViewType.Right, @@ -87,10 +88,10 @@ class MessageViewMailBoxUserView extends AbstractViewNext { this.allowMessageActions = !!Settings.capa(Capa.MessageActions); this.allowMessageListActions = !!Settings.capa(Capa.MessageListActions); - this.logoImg = (Settings.settingsGet('UserLogoMessage')||'').trim(); - this.logoIframe = (Settings.settingsGet('UserIframeMessage')||'').trim(); + this.logoImg = (Settings.get('UserLogoMessage')||'').trim(); + this.logoIframe = (Settings.get('UserIframeMessage')||'').trim(); - this.mobile = !!Settings.appSettingsGet('mobile'); + this.mobile = !!Settings.app('mobile'); this.attachmentsActions = AppStore.attachmentsActions; diff --git a/dev/View/User/Settings/Menu.js b/dev/View/User/Settings/Menu.js index 91085f3c8..f32ae2d1d 100644 --- a/dev/View/User/Settings/Menu.js +++ b/dev/View/User/Settings/Menu.js @@ -3,8 +3,6 @@ import { leftPanelDisabled } from 'Common/Globals'; import { settings, inbox } from 'Common/Links'; import { getFolderInboxName } from 'Common/Cache'; -import * as Settings from 'Storage/Settings'; - import { view, ViewType, setHash, settingsMenuKeysHandler } from 'Knoin/Knoin'; import { AbstractViewNext } from 'Knoin/AbstractViewNext'; @@ -22,7 +20,7 @@ class MenuSettingsUserView extends AbstractViewNext { this.leftPanelDisabled = leftPanelDisabled; - this.mobile = Settings.appSettingsGet('mobile'); + this.mobile = rl.settings.app('mobile'); this.menu = screen.menu; } diff --git a/dev/View/User/Settings/Pane.js b/dev/View/User/Settings/Pane.js index 43ba6ba5f..9d723530f 100644 --- a/dev/View/User/Settings/Pane.js +++ b/dev/View/User/Settings/Pane.js @@ -2,8 +2,6 @@ import { inbox } from 'Common/Links'; import { getFolderInboxName } from 'Common/Cache'; import { leftPanelDisabled } from 'Common/Globals'; -import * as Settings from 'Storage/Settings'; - import MessageStore from 'Stores/User/Message'; import { view, ViewType, setHash } from 'Knoin/Knoin'; @@ -18,7 +16,7 @@ class PaneSettingsUserView extends AbstractViewNext { constructor() { super(); - this.mobile = Settings.appSettingsGet('mobile'); + this.mobile = rl.settings.app('mobile'); this.leftPanelDisabled = leftPanelDisabled; } diff --git a/dev/boot.js b/dev/boot.js index 7deb3624a..0851affb6 100644 --- a/dev/boot.js +++ b/dev/boot.js @@ -4,7 +4,7 @@ const doc = win.document, app = doc.getElementById('rl-app'), - setPercentWidth = percent => setTimeout(() => progress.style.width = parseInt(Math.min(percent, 100)) + '%', 50), + options = app && app.dataset.boot && JSON.parse(app.dataset.boot) || {}, Storage = type => { let name = type+'Storage'; @@ -85,10 +85,10 @@ const }, p = win.progressJs = { - set: percent => setPercentWidth(percent), + set: percent => progress.style.width = Math.min(percent, 100) + '%', end: () => { if (container) { - setPercentWidth(100); + p.set(100); setTimeout(() => { container.remove(); container = progress = null; @@ -100,19 +100,19 @@ const let container = doc.createElement('div'), progress = container.appendChild(doc.createElement("div")), - RL_APP_DATA_STORAGE = null; + RL_APP_DATA_STORAGE = {}; container.className = 'progressjs-progress progressjs-theme-rainloop'; progress.className = "progressjs-inner"; progress.appendChild(doc.createElement('div')).className = "progressjs-percent"; -setPercentWidth(1); +p.set(1); doc.body.append(container); Storage('local'); Storage('session'); -win.RainLoop = { +win.rl = { hash: { // getHash get: () => storage().getItem(STORAGE_KEY) || null, @@ -131,13 +131,30 @@ win.RainLoop = { check: () => { if (timestamp() > (parseInt(storage().getItem(TIME_KEY) || 0, 10) || 0) + 3600000) { // 60m - RainLoop.hash.clear(); + rl.hash.clear(); return true; } return false; } }, - data: () => RL_APP_DATA_STORAGE + data: () => RL_APP_DATA_STORAGE, + adminArea: () => options.admin, + settings: { + get: name => null == RL_APP_DATA_STORAGE[name] ? null : RL_APP_DATA_STORAGE[name], + set: (name, value) => RL_APP_DATA_STORAGE[name] = value, + app: name => { + const APP_SETTINGS = RL_APP_DATA_STORAGE.System || {}; + return null == APP_SETTINGS[name] ? null : APP_SETTINGS[name]; + }, + capa: name => null != name && Array.isArray(RL_APP_DATA_STORAGE.Capa) && RL_APP_DATA_STORAGE.Capa.includes(name) + }, + setWindowTitle: title => { + title = null == title ? '' : '' + title; + if (RL_APP_DATA_STORAGE.Title) { + title += (title ? ' - ' : '') + RL_APP_DATA_STORAGE.Title; + } + document.title = null == title ? '' : '' + title; + } }; // init section @@ -150,7 +167,7 @@ setInterval(setTimestamp, 60000); // 1m win.__initAppData = appData => { RL_APP_DATA_STORAGE = appData; - RainLoop.hash.set(); + rl.hash.set(); if (appData) { const css = appData.IncludeCss, @@ -188,7 +205,7 @@ win.__initAppData = appData => { loadScript(appData.StaticLibJsLink).then(() => { doc.getElementById('rl-check').remove(); if (appData.IncludeBackground) { - const img = appData.IncludeBackground.replace('{{USER}}', RainLoop.hash.get() || '0'); + const img = appData.IncludeBackground.replace('{{USER}}', rl.hash.get() || '0'); if (img) { doc.documentElement.classList.add('UserBackground'); doc.body.style.backgroundImage = "url("+img+")"; @@ -236,10 +253,6 @@ if (!navigator || !navigator.cookieEnabled) { writeCSS('#rl-content{display:none;}.internal-hiddden{display:none !important;}'); if (app) { - const - meta = doc.getElementById('app-boot-data'), - options = meta ? JSON.parse(meta.getAttribute('content')) || {} : {}; - app.innerHTML = '
\
\
\ @@ -248,9 +261,7 @@ if (app) {
\
\
\ -
\ - An error occurred.
Please refresh the page and try again.\ -
\ +
An error occurred.
Please refresh the page and try again.
\
\
\
\ @@ -268,7 +279,7 @@ if (app) { + (options.mobile ? 'mobile' : 'no-mobile') + (options.mobileDevice ? '-1' : '-0') + '/' - + (RainLoop.hash.get() || '0') + + (rl.hash.get() || '0') + '/' + Math.random().toString().substr(2) + '/').then(() => {}); diff --git a/dev/bootstrap.js b/dev/bootstrap.js index a7bab4a3e..ac0ee5450 100644 --- a/dev/bootstrap.js +++ b/dev/bootstrap.js @@ -64,12 +64,7 @@ export default (App) => { cb = () => setTimeout(() => { if (window.rainloopTEMPLATES && rainloopTEMPLATES[0]) { doc.getElementById('rl-templates').innerHTML = rainloopTEMPLATES[0]; - setTimeout(() => { - $htmlCL.remove('no-js', 'rl-booted-trigger'); - $htmlCL.add('rl-booted'); - - App.bootstart(); - }, 10); + setTimeout(() => App.bootstart(), 10); } else { fErrorCallback(); } diff --git a/rainloop/v/0.0.0/app/templates/Index.html b/rainloop/v/0.0.0/app/templates/Index.html index 8b42e643f..81b5cc3bd 100644 --- a/rainloop/v/0.0.0/app/templates/Index.html +++ b/rainloop/v/0.0.0/app/templates/Index.html @@ -1,5 +1,5 @@ - +