snappymail/dev/Storage/Settings.jsx

47 lines
904 B
React
Raw Normal View History

2015-11-15 08:23:16 +08:00
import {window} from 'common';
2016-06-07 05:57:52 +08:00
import {isUnd, isNormal, isArray, inArray} 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
* @return {*}
*/
export function settingsGet(name)
{
return isUnd(SETTINGS[name]) ? null : SETTINGS[name];
}
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {string} name
* @param {*} value
*/
export function settingsSet(name, value)
{
SETTINGS[name] = value;
}
2016-04-30 07:42:18 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {string} name
* @return {*}
*/
export function appSettingsGet(name)
{
return isUnd(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
* @return {boolean}
*/
export function capa(name)
{
const values = settingsGet('Capa');
return isArray(values) && isNormal(name) && -1 < inArray(name, values);
}