Merge pull request #121 from samuelthomas2774/fix-plugin-getsetting
Fix Plugin.getSetting
This commit is contained in:
commit
9aeb5972cd
|
@ -35,8 +35,14 @@ export default class {
|
|||
get enabled() { return this.userConfig.enabled }
|
||||
get pluginConfig() { return this.userConfig.config }
|
||||
|
||||
getSetting(settingId) {
|
||||
return this.userConfig.config.find(setting => setting.id === settingId);
|
||||
getSetting(setting_id, category_id) {
|
||||
for (let category of this.pluginConfig) {
|
||||
if (category_id && category.category !== category_id) return;
|
||||
for (let setting of category.settings) {
|
||||
if (setting.id !== setting_id) return;
|
||||
return setting.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async saveSettings(newSettings) {
|
||||
|
|
|
@ -2,11 +2,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
const { $, moment, _ } = Vendor;
|
||||
const { Events, Logger } = Api;
|
||||
return class extends Plugin {
|
||||
|
||||
return class extends Plugin {
|
||||
onStart() {
|
||||
Events.subscribe('TEST_EVENT', this.eventTest);
|
||||
Logger.log('onStart');
|
||||
Logger.log(`Setting "default-0" value: ${this.getSetting('default-0')}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -19,6 +20,16 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
eventTest(e) {
|
||||
Logger.log(e);
|
||||
}
|
||||
|
||||
settingChanged(category, setting_id, value) {
|
||||
if (!this.enabled) return;
|
||||
Logger.log(`${category}/${setting_id} changed to ${value}`);
|
||||
}
|
||||
|
||||
settingsChanged(settings) {
|
||||
if (!this.enabled) return;
|
||||
Logger.log([ 'Settings updated', settings ]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue