diff --git a/client/src/modules/plugin.js b/client/src/modules/plugin.js index dbbe7de3..b591196f 100644 --- a/client/src/modules/plugin.js +++ b/client/src/modules/plugin.js @@ -12,6 +12,7 @@ export default class { constructor(pluginInternals) { this.__pluginInternals = pluginInternals; + this.saveSettings = this.saveSettings.bind(this); this.hasSettings = this.pluginConfig && this.pluginConfig.length > 0; this.start = this.start.bind(this); this.stop = this.stop.bind(this); @@ -31,6 +32,22 @@ 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); + } + + saveSettings(newSettings) { + let changed = false; + for (let newSetting of newSettings) { + const setting = this.pluginConfig.find(s => s.id === newSetting.id && s.value !== newSetting.value); + if (!setting) continue; + setting.value = newSetting.value; + if (this.settingSaved) this.settingSaved(setting); + changed = true; + } + if (changed && this.settingsSaved) this.settingsSaved(this.pluginConfig); + } + start() { if (this.onStart) { const started = this.onStart(); diff --git a/client/src/ui/components/bd/PluginSettingsModal.vue b/client/src/ui/components/bd/PluginSettingsModal.vue index 8cdb2e20..2e48810a 100644 --- a/client/src/ui/components/bd/PluginSettingsModal.vue +++ b/client/src/ui/components/bd/PluginSettingsModal.vue @@ -11,56 +11,60 @@ \ No newline at end of file diff --git a/client/src/ui/components/bd/pluginsetting/Bool.vue b/client/src/ui/components/bd/pluginsetting/Bool.vue new file mode 100644 index 00000000..acb3f48d --- /dev/null +++ b/client/src/ui/components/bd/pluginsetting/Bool.vue @@ -0,0 +1,27 @@ +/** + * BetterDiscord Plugin Setting Bool Component + * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks + * All rights reserved. + * https://betterdiscord.net + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. +*/ + + + \ No newline at end of file diff --git a/client/src/ui/components/bd/pluginsetting/PluginSetting.vue b/client/src/ui/components/bd/pluginsetting/PluginSetting.vue new file mode 100644 index 00000000..39644a85 --- /dev/null +++ b/client/src/ui/components/bd/pluginsetting/PluginSetting.vue @@ -0,0 +1,29 @@ +/** + * BetterDiscord Plugin Setting Component + * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks + * All rights reserved. + * https://betterdiscord.net + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. +*/ + + + diff --git a/client/src/ui/components/bd/pluginsetting/String.vue b/client/src/ui/components/bd/pluginsetting/String.vue new file mode 100644 index 00000000..058195a5 --- /dev/null +++ b/client/src/ui/components/bd/pluginsetting/String.vue @@ -0,0 +1,31 @@ +/** + * BetterDiscord Plugin Setting String Component + * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks + * All rights reserved. + * https://betterdiscord.net + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. +*/ + + +