From d148c486f537475b44346be7e8c01b67770ee6b4 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Wed, 29 Nov 2017 14:22:29 +0100 Subject: [PATCH] Load/Unload theme without restarting (#2458) --- app/ui/window.js | 9 ++++++++- lib/reducers/ui.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/ui/window.js b/app/ui/window.js index 1377ce4d..1b697a06 100644 --- a/app/ui/window.js +++ b/app/ui/window.js @@ -36,6 +36,11 @@ module.exports = class Window { const rpc = createRPC(window); const sessions = new Map(); + const updateBackgroundColor = () => { + const cfg_ = app.plugins.getDecoratedConfig(); + window.setBackgroundColor(toElectronBackgroundColor(cfg_.backgroundColor || '#000')); + }; + // config changes const cfgUnsubscribe = app.config.subscribe(() => { const cfg_ = app.plugins.getDecoratedConfig(); @@ -49,11 +54,12 @@ module.exports = class Window { } // update background color if necessary + updateBackgroundColor(); + cfg = cfg_; }); rpc.on('init', () => { - window.setBackgroundColor(toElectronBackgroundColor(cfg.backgroundColor || '#000')); window.show(); // If no callback is passed to createWindow, @@ -234,6 +240,7 @@ module.exports = class Window { if (!err) { load(); window.webContents.send('plugins change'); + updateBackgroundColor(); } }); diff --git a/lib/reducers/ui.js b/lib/reducers/ui.js index 09f24ef7..99e11b34 100644 --- a/lib/reducers/ui.js +++ b/lib/reducers/ui.js @@ -155,7 +155,7 @@ const reducer = (state = initial, action) => { ret.backgroundColor = config.backgroundColor; } - if (config.css) { + if (config.css || config.css === '') { ret.css = config.css; }