From f50bd32fa3b4223da0efc6f6fdb3952e56005817 Mon Sep 17 00:00:00 2001 From: TC Date: Thu, 4 Mar 2021 23:09:01 +0100 Subject: [PATCH] Fix resumeOnStart option --- config/defaults.js | 2 +- config/index.js | 2 ++ config/store.js | 5 +++++ index.js | 4 +++- menu.js | 6 +++--- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/config/defaults.js b/config/defaults.js index cf417b58..6238e114 100644 --- a/config/defaults.js +++ b/config/defaults.js @@ -14,7 +14,7 @@ const defaultConfig = { restartOnConfigChanges: false, trayClickPlayPause: false, autoResetAppCache: false, - resumeSongOnStart: true + resumeOnStart: true, }, plugins: { // Enabled plugins diff --git a/config/index.js b/config/index.js index 8b4e5c79..c77e4d00 100644 --- a/config/index.js +++ b/config/index.js @@ -1,3 +1,4 @@ +const defaultConfig = require("./defaults"); const plugins = require("./plugins"); const store = require("./store"); @@ -10,6 +11,7 @@ const get = (key) => { }; module.exports = { + defaultConfig, get, set, edit: () => store.openInEditor(), diff --git a/config/store.js b/config/store.js index 85c39be7..9c0de1e4 100644 --- a/config/store.js +++ b/config/store.js @@ -3,6 +3,11 @@ const Store = require("electron-store"); const defaults = require("./defaults"); const migrations = { + ">=1.11.0": (store) => { + if (store.get("options.resumeOnStart") === undefined) { + store.set("options.resumeOnStart", true); + } + }, ">=1.7.0": (store) => { const enabledPlugins = store.get("plugins"); if (!Array.isArray(enabledPlugins)) { diff --git a/index.js b/index.js index 44631d0e..8b687673 100644 --- a/index.js +++ b/index.js @@ -111,7 +111,9 @@ function createMainWindow() { win.maximize(); } - const urlToLoad = config.get("resumeOnStart") ? config.get("url") : "https://music.youtube.com"; + const urlToLoad = config.get("options.resumeOnStart") + ? config.get("url") + : config.defaultConfig.url; win.webContents.loadURL(urlToLoad); win.on("closed", onClosed); diff --git a/menu.js b/menu.js index 14f8e04a..222fac90 100644 --- a/menu.js +++ b/menu.js @@ -69,10 +69,10 @@ const mainMenuTemplate = (win) => [ { label: "Resume last song when app starts", type: "checkbox", - checked: config.get("options.resumeSongOnStart"), + checked: config.get("options.resumeOnStart"), click: (item) => { - config.set("options.resumeSongOnStart", item.checked); - } + config.set("options.resumeOnStart", item.checked); + }, }, ...(is.windows() || is.linux() ? [