Use Plugin/Theme.config

This commit is contained in:
Samuel Elliott 2018-02-14 15:45:10 +00:00
parent 0af22b21d4
commit 1dd01e186b
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
3 changed files with 12 additions and 12 deletions

View File

@ -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

View File

@ -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);

View File

@ -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() {