Save plugin config when enabled/disabled
This commit is contained in:
parent
9fb51c57b3
commit
6e4d6307e8
|
@ -166,4 +166,4 @@ export default class {
|
||||||
static getContentByPath(path) { return this.localContent.find(c => c.contentPath === path) }
|
static getContentByPath(path) { return this.localContent.find(c => c.contentPath === path) }
|
||||||
static getContentByDirName(dirName) { return this.localContent.find(c => c.dirName === dirName) }
|
static getContentByDirName(dirName) { return this.localContent.find(c => c.dirName === dirName) }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,13 +44,15 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveSettings(newSettings) {
|
async saveSettings(newSettings) {
|
||||||
for (let category of newSettings) {
|
if (newSettings) {
|
||||||
const oldCategory = this.pluginConfig.find(c => c.category === category.category);
|
for (let category of newSettings) {
|
||||||
for (let setting of category.settings) {
|
const oldCategory = this.pluginConfig.find(c => c.category === category.category);
|
||||||
const oldSetting = oldCategory.settings.find(s => s.id === setting.id);
|
for (let setting of category.settings) {
|
||||||
if (oldSetting.value === setting.value) continue;
|
const oldSetting = oldCategory.settings.find(s => s.id === setting.id);
|
||||||
oldSetting.value = setting.value;
|
if (oldSetting.value === setting.value) continue;
|
||||||
if (this.settingChanged) this.settingChanged(category.category, setting.id, setting.value);
|
oldSetting.value = setting.value;
|
||||||
|
if (this.settingChanged) this.settingChanged(category.category, setting.id, setting.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,25 +70,23 @@ export default class {
|
||||||
start() {
|
start() {
|
||||||
if (this.onStart) {
|
if (this.onStart) {
|
||||||
const started = this.onStart();
|
const started = this.onStart();
|
||||||
if (started) {
|
if (!started) return false;
|
||||||
return this.userConfig.enabled = true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return this.userConfig.enabled = true; //Assume plugin started since it doesn't have onStart
|
|
||||||
|
this.userConfig.enabled = true;
|
||||||
|
this.saveSettings();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
if (this.onStop) {
|
if (this.onStop) {
|
||||||
const stopped = this.onStop();
|
const stopped = this.onStop();
|
||||||
if (stopped) {
|
if (!stopped) return false;
|
||||||
this.userConfig.enabled = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.userConfig.enabled = false;
|
this.userConfig.enabled = false;
|
||||||
return true; //Assume plugin stopped since it doesn't have onStop
|
this.saveSettings();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue