From e574b6c6e50fb45eae56bc87e59d970be92b3118 Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Fri, 25 Feb 2022 17:58:31 -0800 Subject: [PATCH] adjustments to theme reloading --- src/renderer/index.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/renderer/index.js b/src/renderer/index.js index 94594794..6dd9cb2d 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -781,6 +781,7 @@ const app = new Vue({ ipcRenderer.on('theme-update', (event, arg) => { less.refresh(true, true, true) + self.setTheme(self.cfg.visual.theme, true) }) ipcRenderer.on('SoundCheckTag', (event, tag) => { @@ -902,7 +903,7 @@ const app = new Vue({ }, 500) ipcRenderer.invoke("renderer-ready", true) }, - async setTheme(theme = "") { + async setTheme(theme = "", onlyPrefs = false) { console.log(theme) if (this.cfg.visual.theme == "") { this.cfg.visual.theme = "default.less" @@ -913,14 +914,20 @@ const app = new Vue({ this.cfg.visual.theme = "" this.cfg.visual.theme = theme } - this.chrome.appliedTheme.info = await (await fetch("themes/" + app.cfg.visual.theme.replace("index.less", "theme.json"))).json() + const info = {} + try { + info = await (await fetch("themes/" + app.cfg.visual.theme.replace("index.less", "theme.json"))).json() + }catch(e){e=null} + this.chrome.appliedTheme.info = info - document.querySelector("#userTheme").href = `themes/${this.cfg.visual.theme}` - document.querySelectorAll(`[id*='less']`).forEach(el => { - el.remove() - }); - less.refresh() + if(!onlyPrefs) { + document.querySelector("#userTheme").href = `themes/${this.cfg.visual.theme}` + document.querySelectorAll(`[id*='less']`).forEach(el => { + el.remove() + }); + less.refresh() + } }, getThemeDirective(directive = "") { if(typeof this.chrome.appliedTheme.info != "object") {