Fix resumeOnStart option

This commit is contained in:
TC
2021-03-04 23:09:01 +01:00
parent 0dcf820944
commit f50bd32fa3
5 changed files with 14 additions and 5 deletions

View File

@ -14,7 +14,7 @@ const defaultConfig = {
restartOnConfigChanges: false, restartOnConfigChanges: false,
trayClickPlayPause: false, trayClickPlayPause: false,
autoResetAppCache: false, autoResetAppCache: false,
resumeSongOnStart: true resumeOnStart: true,
}, },
plugins: { plugins: {
// Enabled plugins // Enabled plugins

View File

@ -1,3 +1,4 @@
const defaultConfig = require("./defaults");
const plugins = require("./plugins"); const plugins = require("./plugins");
const store = require("./store"); const store = require("./store");
@ -10,6 +11,7 @@ const get = (key) => {
}; };
module.exports = { module.exports = {
defaultConfig,
get, get,
set, set,
edit: () => store.openInEditor(), edit: () => store.openInEditor(),

View File

@ -3,6 +3,11 @@ const Store = require("electron-store");
const defaults = require("./defaults"); const defaults = require("./defaults");
const migrations = { const migrations = {
">=1.11.0": (store) => {
if (store.get("options.resumeOnStart") === undefined) {
store.set("options.resumeOnStart", true);
}
},
">=1.7.0": (store) => { ">=1.7.0": (store) => {
const enabledPlugins = store.get("plugins"); const enabledPlugins = store.get("plugins");
if (!Array.isArray(enabledPlugins)) { if (!Array.isArray(enabledPlugins)) {

View File

@ -111,7 +111,9 @@ function createMainWindow() {
win.maximize(); 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.webContents.loadURL(urlToLoad);
win.on("closed", onClosed); win.on("closed", onClosed);

View File

@ -69,10 +69,10 @@ const mainMenuTemplate = (win) => [
{ {
label: "Resume last song when app starts", label: "Resume last song when app starts",
type: "checkbox", type: "checkbox",
checked: config.get("options.resumeSongOnStart"), checked: config.get("options.resumeOnStart"),
click: (item) => { click: (item) => {
config.set("options.resumeSongOnStart", item.checked); config.set("options.resumeOnStart", item.checked);
} },
}, },
...(is.windows() || is.linux() ...(is.windows() || is.linux()
? [ ? [