mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-07 07:18:39 +08:00
aeb5275648
Put dev/Storage/Settings.js in boots.js global rl.settings
65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
import { data as GlobalsData } from 'Common/Globals';
|
|
|
|
const USER_VIEW_MODELS_HOOKS = [],
|
|
ADMIN_VIEW_MODELS_HOOKS = [];
|
|
|
|
/**
|
|
* @param {string} name
|
|
* @returns {?}
|
|
*/
|
|
export function mainSettingsGet(name) {
|
|
return rl.settings.get(name);
|
|
}
|
|
|
|
/**
|
|
* @param {Function} callback
|
|
* @param {string} action
|
|
* @param {Object=} parameters
|
|
* @param {?number=} timeout
|
|
*/
|
|
export function remoteRequest(callback, action, parameters, timeout) {
|
|
if (GlobalsData.__APP__) {
|
|
GlobalsData.__APP__.remote().defaultRequest(callback, 'Plugin' + action, parameters, timeout);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param {Function} SettingsViewModelClass
|
|
* @param {string} labelName
|
|
* @param {string} template
|
|
* @param {string} route
|
|
*/
|
|
export function addSettingsViewModel(SettingsViewModelClass, template, labelName, route) {
|
|
USER_VIEW_MODELS_HOOKS.push([SettingsViewModelClass, template, labelName, route]);
|
|
}
|
|
|
|
/**
|
|
* @param {Function} SettingsViewModelClass
|
|
* @param {string} labelName
|
|
* @param {string} template
|
|
* @param {string} route
|
|
*/
|
|
export function addSettingsViewModelForAdmin(SettingsViewModelClass, template, labelName, route) {
|
|
ADMIN_VIEW_MODELS_HOOKS.push([SettingsViewModelClass, template, labelName, route]);
|
|
}
|
|
|
|
/**
|
|
* @param {boolean} admin
|
|
*/
|
|
export function runSettingsViewModelHooks(admin) {
|
|
const Knoin = require('Knoin/Knoin');
|
|
(admin ? ADMIN_VIEW_MODELS_HOOKS : USER_VIEW_MODELS_HOOKS).forEach(view => {
|
|
Knoin.addSettingsViewModel(view[0], view[1], view[2], view[3]);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @param {string} pluginSection
|
|
* @param {string} name
|
|
* @returns {?}
|
|
*/
|
|
export function settingsGet(pluginSection, name) {
|
|
let plugins = rl.settings.get('Plugins');
|
|
plugins = plugins && null != plugins[pluginSection] ? plugins[pluginSection] : null;
|
|
return plugins ? (null == plugins[name] ? null : plugins[name]) : null;
|
|
}
|