From 5370b0976f17796a388f308d5f0aad93447f01ab Mon Sep 17 00:00:00 2001 From: mosu forge Date: Fri, 26 Oct 2018 18:08:50 -0700 Subject: [PATCH] persist theme preference in localstorage to reduce dark/light flicker upon startup --- quasar.conf.js | 1 + src/gateway/gateway.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/quasar.conf.js b/quasar.conf.js index 8d98ffc..eabf426 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -96,6 +96,7 @@ module.exports = function (ctx) { plugins: [ "Notify", "Loading", + "LocalStorage", "Dialog" ] // iconSet: ctx.theme.mat ? "material-icons" : "ionicons" diff --git a/src/gateway/gateway.js b/src/gateway/gateway.js index 8fa4696..36de8d3 100644 --- a/src/gateway/gateway.js +++ b/src/gateway/gateway.js @@ -1,5 +1,5 @@ import { ipcRenderer } from "electron" -import { Notify, Dialog, Loading } from "quasar" +import { Notify, Dialog, Loading, LocalStorage } from "quasar" import { SCEE } from "./SCEE-Node"; import * as WebSocket from "ws" @@ -12,13 +12,17 @@ export class Gateway { this.token = null this.scee = new SCEE() + let theme = LocalStorage.has("theme") ? LocalStorage.get.item("theme") : "light" this.app.store.commit("gateway/set_app_data", { config: { appearance: { - theme: "dark" + theme } } }); + this.app.store.watch( state => state.gateway.app.config.appearance.theme, (theme) => { + LocalStorage.set("theme", theme) + }) this.closeDialog = false