snappymail/dev/Storage/Settings.js

41 lines
867 B
JavaScript
Raw Normal View History

import { isNormal } from 'Common/Utils';
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
let SETTINGS = window.__rlah_data() || null;
SETTINGS = isNormal(SETTINGS) ? SETTINGS : {};
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
let APP_SETTINGS = SETTINGS.System || null;
APP_SETTINGS = isNormal(APP_SETTINGS) ? APP_SETTINGS : {};
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {string} name
2016-06-30 08:02:45 +08:00
* @returns {*}
2016-06-16 07:36:44 +08:00
*/
2019-07-05 03:19:24 +08:00
export function settingsGet(name) {
return undefined === SETTINGS[name] ? null : SETTINGS[name];
2016-06-16 07:36:44 +08:00
}
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {string} name
* @param {*} value
*/
2019-07-05 03:19:24 +08:00
export function settingsSet(name, value) {
2016-06-16 07:36:44 +08:00
SETTINGS[name] = value;
}
2016-04-30 07:42:18 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {string} name
2016-06-30 08:02:45 +08:00
* @returns {*}
2016-06-16 07:36:44 +08:00
*/
2019-07-05 03:19:24 +08:00
export function appSettingsGet(name) {
return undefined === APP_SETTINGS[name] ? null : APP_SETTINGS[name];
2015-11-15 08:23:16 +08:00
}
2016-06-16 07:36:44 +08:00
/**
* @param {string} name
2016-06-30 08:02:45 +08:00
* @returns {boolean}
2016-06-16 07:36:44 +08:00
*/
2019-07-05 03:19:24 +08:00
export function capa(name) {
2016-06-16 07:36:44 +08:00
const values = settingsGet('Capa');
return Array.isArray(values) && isNormal(name) && values.includes(name);
2016-06-16 07:36:44 +08:00
}