From 1dd01e186b68fdd7f0bad49546cb9521ffcad23e Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Wed, 14 Feb 2018 15:45:10 +0000 Subject: [PATCH] Use Plugin/Theme.config --- client/src/modules/plugin.js | 10 +++++----- client/src/modules/theme.js | 12 ++++++------ client/src/ui/modals.js | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/src/modules/plugin.js b/client/src/modules/plugin.js index 68955d5e..b4fd7fec 100644 --- a/client/src/modules/plugin.js +++ b/client/src/modules/plugin.js @@ -38,7 +38,7 @@ export default class Plugin { constructor(pluginInternals) { this.__pluginInternals = pluginInternals; this.saveSettings = this.saveSettings.bind(this); - this.hasSettings = this.pluginConfig && this.pluginConfig.length > 0; + this.hasSettings = this.config && this.config.length > 0; this.start = this.start.bind(this); this.stop = this.stop.bind(this); } @@ -64,7 +64,7 @@ export default class Plugin { get events() { return this.EventEmitter ? this.EventEmitter : (this.EventEmitter = new PluginEvents(this)) } getSetting(setting_id, category_id) { - for (let category of this.pluginConfig) { + for (let category of this.config) { if (category_id && category.category !== category_id) return; for (let setting of category.settings) { if (setting.id !== setting_id) return; @@ -81,7 +81,7 @@ export default class Plugin { const updatedSettings = []; for (let newCategory of newSettings) { - const category = this.pluginConfig.find(c => c.category === newCategory.category); + const category = this.config.find(c => c.category === newCategory.category); for (let newSetting of newCategory.settings) { const setting = category.settings.find(s => s.id === newSetting.id); if (Utils.compare(setting.value, newSetting.value)) continue; @@ -109,9 +109,9 @@ export default class Plugin { } async saveConfiguration() { - window.testConfig = new ContentConfig(this.pluginConfig); + window.testConfig = new ContentConfig(this.config); try { - const config = new ContentConfig(this.pluginConfig).strip(); + const config = new ContentConfig(this.config).strip(); await FileUtils.writeFile(`${this.pluginPath}/user.config.json`, JSON.stringify({ enabled: this.enabled, config diff --git a/client/src/modules/theme.js b/client/src/modules/theme.js index 5cf124e9..75506d9e 100644 --- a/client/src/modules/theme.js +++ b/client/src/modules/theme.js @@ -12,7 +12,7 @@ import ThemeManager from './thememanager'; import { EventEmitter } from 'events'; import { SettingUpdatedEvent, SettingsUpdatedEvent } from 'structs'; import { DOM, Modals } from 'ui'; -import { FileUtils, ClientIPC } from 'common'; +import { Utils, FileUtils, ClientIPC } from 'common'; import ContentConfig from './contentconfig'; class ThemeEvents { @@ -38,7 +38,7 @@ export default class Theme { constructor(themeInternals) { this.__themeInternals = themeInternals; - this.hasSettings = this.themeConfig && this.themeConfig.length > 0; + this.hasSettings = this.config && this.config.length > 0; this.saveSettings = this.saveSettings.bind(this); this.enable = this.enable.bind(this); this.disable = this.disable.bind(this); @@ -71,10 +71,10 @@ export default class Theme { const updatedSettings = []; for (let newCategory of newSettings) { - const category = this.themeConfig.find(c => c.category === newCategory.category); + const category = this.config.find(c => c.category === newCategory.category); for (let newSetting of newCategory.settings) { const setting = category.settings.find(s => s.id === newSetting.id); - if (setting.value === newSetting.value) continue; + if (Utils.compare(setting.value, newSetting.value)) continue; const old_value = setting.value; setting.value = newSetting.value; @@ -103,7 +103,7 @@ export default class Theme { async saveConfiguration() { try { - const config = new ContentConfig(this.themeConfig).strip(); + const config = new ContentConfig(this.config).strip(); await FileUtils.writeFile(`${this.themePath}/user.config.json`, JSON.stringify({ enabled: this.enabled, config, @@ -134,7 +134,7 @@ export default class Theme { let css = ''; if (this.info.type === 'sass') { css = await ClientIPC.send('bd-compileSass', { - data: ThemeManager.getConfigAsSCSS(this.themeConfig), + data: ThemeManager.getConfigAsSCSS(this.config), path: this.paths.mainPath.replace(/\\/g, '/') }); console.log(css); diff --git a/client/src/ui/modals.js b/client/src/ui/modals.js index 33b2b918..e98e7564 100644 --- a/client/src/ui/modals.js +++ b/client/src/ui/modals.js @@ -109,7 +109,7 @@ export default class { static themeSettings(theme) { // return this.add({ headertext: theme.name + ' Settings', settings: theme.config, saveSettings: theme.saveSettings }, SettingsModal); - return this.settings(theme.name + ' Settings', theme.themeConfig, null, null, theme.saveSettings.bind(theme)); + return this.settings(theme.name + ' Settings', theme.config, null, null, theme.saveSettings.bind(theme)); } static get stack() {