Improve Settings handling

This commit is contained in:
djmaze 2021-03-10 11:44:48 +01:00
parent e7b1ce7509
commit 34b25eedea
39 changed files with 160 additions and 150 deletions

View file

@ -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]);

View file

@ -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);
}

View file

@ -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 });

View file

@ -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}

View file

@ -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;
};

View file

@ -504,5 +504,5 @@ export function mailToHelper(mailToUrl) {
export function showMessageComposer(params = [])
{
rl.app.showScreenPopup(params);
rl.app.showMessageComposer(params);
}

View file

@ -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,

View file

@ -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);
}
},

View file

@ -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,
'',

View file

@ -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'));
}
}

View file

@ -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() {

View file

@ -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);
}
}

View file

@ -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')
]);
}
}

View file

@ -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() {

View file

@ -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;

View file

@ -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: '',

View file

@ -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;

View file

@ -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 });

View file

@ -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);

View file

@ -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 });

View file

@ -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));
*/
}

View file

@ -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));

View file

@ -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'));
}
}

View file

@ -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());

View file

@ -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'));
}
}

View file

@ -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');
}
}

View file

@ -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'));
}
}

View file

@ -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()

View file

@ -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'));
}
}

View file

@ -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();
}

View file

@ -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: '',

View file

@ -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;

View file

@ -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',

View file

@ -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());

View file

@ -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: {

View file

@ -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;

View file

@ -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:

View file

@ -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);

6
dev/bootstrap.js vendored
View file

@ -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) => {