From 3ab655594bb87cd421032c534e011078b24edb53 Mon Sep 17 00:00:00 2001 From: Strencher <46447572+Strencher@users.noreply.github.com> Date: Wed, 9 Dec 2020 22:44:11 +0100 Subject: [PATCH] Improve styleloader, fix clearing emotes. (#506) * improve styleloader for local development. * fix clearing emotes --- src/builtins/emotes/emotes.js | 2 +- src/modules/core.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/builtins/emotes/emotes.js b/src/builtins/emotes/emotes.js index 1ba5ee7c..9df0531c 100644 --- a/src/builtins/emotes/emotes.js +++ b/src/builtins/emotes/emotes.js @@ -62,7 +62,7 @@ export default new class EmoteModule extends Builtin { } async enabled() { - Settings.registerCollection("emotes", "Emotes", EmoteConfig, {title: Strings.Emotes.clearEmotes, onClick: this.resetEmotes}); + Settings.registerCollection("emotes", "Emotes", EmoteConfig, {title: Strings.Emotes.clearEmotes, onClick: this.resetEmotes.bind(this)}); await this.getBlocklist(); await this.loadEmoteData(); diff --git a/src/modules/core.js b/src/modules/core.js index cef98540..c443bae3 100644 --- a/src/modules/core.js +++ b/src/modules/core.js @@ -124,11 +124,16 @@ export default new class Core { async loadDependencies() { for (const data of this.dependencies) { - if (Config.local && Config.localPath && data.localPath) { - if (fs.existsSync(path.resolve(Config.localPath, data.localPath))) { - const css = fs.readFileSync(path.resolve(Config.localPath, data.localPath)).toString(); + if (Config.local && Config.localPath && data.localPath && data.type == "style") { + const stylepath = path.resolve(Config.localPath, data.localPath); + if (fs.existsSync(stylepath)) { + Logger.log("Startup", `Loading local stylesheet from (${stylepath})`); + const css = fs.readFileSync(stylepath).toString(); DOMManager.injectStyle(data.name, css); continue; + } + else { + Logger.warn("Startup", "Local stylesheet was not found, loading remote..."); } } const url = Utilities.formatString(data.url, {hash: Config.hash});