fix changing settings when plugin is disabled

This commit is contained in:
Araxeus
2021-04-17 05:08:07 +03:00
parent 834202411d
commit 49698ea669
2 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,12 @@
/*
this is used to determine if plugin is actually active
(not if its only enabled in options)
*/
let enabled = false;
module.exports = (win,options) => {
enabled = true;
};
module.exports.enabled = () => {
return enabled;
};

View File

@ -1,10 +1,19 @@
const { enabled } = require("./back")
const { setOptions } = require("../../config/plugins");
module.exports = (win, options) => [
{
label: "Arrowkeys controls",
type: "checkbox",
checked: !!options.arrowsShortcut,
click: (item) => {
win.webContents.send("setArrowsShortcut", item.checked);
//dynamically change setting if plugin enabled
if (enabled()) {
win.webContents.send("setArrowsShortcut", item.checked);
} else { //fallback to usual method if disabled
options.arrowsShortcut = item.checked;
setOptions("precise-volume", options);
}
}
}
];