Load/Unload theme without restarting (#2458)

This commit is contained in:
CHaBou 2017-11-29 14:22:29 +01:00 committed by GitHub
parent a59ccc3ff4
commit d148c486f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -36,6 +36,11 @@ module.exports = class Window {
const rpc = createRPC(window); const rpc = createRPC(window);
const sessions = new Map(); const sessions = new Map();
const updateBackgroundColor = () => {
const cfg_ = app.plugins.getDecoratedConfig();
window.setBackgroundColor(toElectronBackgroundColor(cfg_.backgroundColor || '#000'));
};
// config changes // config changes
const cfgUnsubscribe = app.config.subscribe(() => { const cfgUnsubscribe = app.config.subscribe(() => {
const cfg_ = app.plugins.getDecoratedConfig(); const cfg_ = app.plugins.getDecoratedConfig();
@ -49,11 +54,12 @@ module.exports = class Window {
} }
// update background color if necessary // update background color if necessary
updateBackgroundColor();
cfg = cfg_; cfg = cfg_;
}); });
rpc.on('init', () => { rpc.on('init', () => {
window.setBackgroundColor(toElectronBackgroundColor(cfg.backgroundColor || '#000'));
window.show(); window.show();
// If no callback is passed to createWindow, // If no callback is passed to createWindow,
@ -234,6 +240,7 @@ module.exports = class Window {
if (!err) { if (!err) {
load(); load();
window.webContents.send('plugins change'); window.webContents.send('plugins change');
updateBackgroundColor();
} }
}); });

View file

@ -155,7 +155,7 @@ const reducer = (state = initial, action) => {
ret.backgroundColor = config.backgroundColor; ret.backgroundColor = config.backgroundColor;
} }
if (config.css) { if (config.css || config.css === '') {
ret.css = config.css; ret.css = config.css;
} }