Option to restart the app on config changes

This commit is contained in:
TC
2020-12-03 22:29:46 +01:00
parent 6ab01056e0
commit fd97576611
4 changed files with 19 additions and 4 deletions

View File

@ -11,6 +11,7 @@ const defaultConfig = {
hideMenu: false, hideMenu: false,
startAtLogin: false, startAtLogin: false,
disableHardwareAcceleration: false, disableHardwareAcceleration: false,
restartOnConfigChanges: false,
}, },
plugins: { plugins: {
// Enabled plugins // Enabled plugins

View File

@ -13,6 +13,9 @@ module.exports = {
get, get,
set, set,
edit: () => store.openInEditor(), edit: () => store.openInEditor(),
watch: (cb) => store.onDidAnyChange(cb), watch: (cb) => {
store.onDidChange("options", cb);
store.onDidChange("plugins", cb);
},
plugins, plugins,
}; };

View File

@ -189,9 +189,12 @@ app.on("activate", () => {
app.on("ready", () => { app.on("ready", () => {
mainWindow = createMainWindow(); mainWindow = createMainWindow();
setApplicationMenu(mainWindow); setApplicationMenu(mainWindow);
if (config.get("options.restartOnConfigChanges")) {
config.watch(() => { config.watch(() => {
setApplicationMenu(mainWindow); app.relaunch();
app.exit();
}); });
}
setUpTray(app, mainWindow); setUpTray(app, mainWindow);
// Autostart at login // Autostart at login

View File

@ -50,6 +50,14 @@ const mainMenuTemplate = (win) => [
config.set("options.disableHardwareAcceleration", item.checked); config.set("options.disableHardwareAcceleration", item.checked);
}, },
}, },
{
label: "Restart on config changes",
type: "checkbox",
checked: config.get("options.restartOnConfigChanges"),
click: (item) => {
config.set("options.restartOnConfigChanges", item.checked);
},
},
...(is.windows() || is.linux() ...(is.windows() || is.linux()
? [ ? [
{ {