mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 12:42:06 +00:00
lint
This commit is contained in:
@ -36,13 +36,15 @@ function registerShortcuts(win, options) {
|
|||||||
if (global) {
|
if (global) {
|
||||||
for (const action in global) {
|
for (const action in global) {
|
||||||
if (!global[action]) {
|
if (!global[action]) {
|
||||||
return; //accelerator is empty
|
continue; //accelerator is empty
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug("Registering global shortcut", global[action], ":", action);
|
console.debug("Registering global shortcut", global[action], ":", action);
|
||||||
if (!songControls[action]) {
|
if (!songControls[action]) {
|
||||||
console.warn("Invalid action", action);
|
console.warn("Invalid action", action);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_registerGlobalShortcut(win.webContents, global[action], songControls[action]);
|
_registerGlobalShortcut(win.webContents, global[action], songControls[action]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,13 +52,15 @@ function registerShortcuts(win, options) {
|
|||||||
if (local) {
|
if (local) {
|
||||||
for (const action in local) {
|
for (const action in local) {
|
||||||
if (!local[action]) {
|
if (!local[action]) {
|
||||||
return; //accelerator is empty
|
continue; //accelerator is empty
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug("Registering local shortcut", local[action], ":", action);
|
console.debug("Registering local shortcut", local[action], ":", action);
|
||||||
if (!songControls[action]) {
|
if (!songControls[action]) {
|
||||||
console.warn("Invalid action", action);
|
console.warn("Invalid action", action);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_registerLocalShortcut(win, local[action], songControls[action]);
|
_registerLocalShortcut(win, local[action], songControls[action]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,16 +71,18 @@ function updateOptions(options) {
|
|||||||
let updated = false;
|
let updated = false;
|
||||||
for (const optionType of ["global", "local"]) {
|
for (const optionType of ["global", "local"]) {
|
||||||
if (Array.isArray(options[optionType])) {
|
if (Array.isArray(options[optionType])) {
|
||||||
const updatedOptions = {}
|
const updatedOptions = {};
|
||||||
for (const obj of options[optionType]) {
|
for (const optionObject of options[optionType]) {
|
||||||
if (obj.action && obj.shortcut) {
|
if (optionObject.action && optionObject.shortcut) {
|
||||||
updatedOptions[obj.action] = obj.shortcut;
|
updatedOptions[optionObject.action] = optionObject.shortcut;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options[optionType] = updatedOptions;
|
options[optionType] = updatedOptions;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
setOptions("shortcuts", options);
|
setOptions("shortcuts", options);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,13 +4,6 @@ const prompt = require("custom-electron-prompt");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const is = require("electron-is");
|
const is = require("electron-is");
|
||||||
|
|
||||||
function setOption(options, key = null, newValue = null) {
|
|
||||||
if (key && newValue) {
|
|
||||||
options[key] = newValue;
|
|
||||||
}
|
|
||||||
setOptions("shortcuts", options)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = (win, options) => [
|
module.exports = (win, options) => [
|
||||||
{
|
{
|
||||||
label: "Set Global Song Controls",
|
label: "Set Global Song Controls",
|
||||||
@ -20,11 +13,19 @@ module.exports = (win, options) => [
|
|||||||
label: "Override MediaKeys",
|
label: "Override MediaKeys",
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
checked: options.overrideMediaKeys,
|
checked: options.overrideMediaKeys,
|
||||||
click: (item) => setOption(options, "overrideMediaKeys", item.checked)
|
click: item => setOption(options, "overrideMediaKeys", item.checked)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const kb = (label_, value_, default_) => { return { value: value_, label: label_, default: default_ || undefined } };
|
function setOption(options, key = null, newValue = null) {
|
||||||
|
if (key && newValue) {
|
||||||
|
options[key] = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
setOptions("shortcuts", options);
|
||||||
|
}
|
||||||
|
|
||||||
|
const kb = (label_, value_, default_) => { return { value: value_, label: label_, default: default_ || undefined }; };
|
||||||
const iconPath = path.join(process.cwd(), "assets", "youtube-music-tray.png");
|
const iconPath = path.join(process.cwd(), "assets", "youtube-music-tray.png");
|
||||||
|
|
||||||
function promptKeybind(options, win) {
|
function promptKeybind(options, win) {
|
||||||
@ -36,11 +37,12 @@ function promptKeybind(options, win) {
|
|||||||
keybindOptions: [
|
keybindOptions: [
|
||||||
kb("Previous", "previous", options.global?.previous),
|
kb("Previous", "previous", options.global?.previous),
|
||||||
kb("Play / Pause", "playPause", options.global?.playPause),
|
kb("Play / Pause", "playPause", options.global?.playPause),
|
||||||
kb("Next", "next", options.global?.next),
|
kb("Next", "next", options.global?.next)
|
||||||
],
|
],
|
||||||
customStylesheet: "dark",
|
customStylesheet: "dark",
|
||||||
height: 250
|
height: 250
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!is.macOS()) {
|
if (!is.macOS()) {
|
||||||
Object.assign(promptOptions, {
|
Object.assign(promptOptions, {
|
||||||
frame: false,
|
frame: false,
|
||||||
@ -49,15 +51,17 @@ function promptKeybind(options, win) {
|
|||||||
height: 270
|
height: 270
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt(promptOptions, win)
|
prompt(promptOptions, win)
|
||||||
.then(output => {
|
.then(output => {
|
||||||
if (output) {
|
if (output) {
|
||||||
for (const keybindObj of output) {
|
for (const keybindObject of output) {
|
||||||
options.global[keybindObj.value] = keybindObj.accelerator;
|
options.global[keybindObject.value] = keybindObject.accelerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
setOption(options);
|
||||||
}
|
}
|
||||||
setOption(options);
|
// else -> pressed cancel
|
||||||
}
|
})
|
||||||
//else = pressed cancel
|
.catch(console.error);
|
||||||
})
|
}
|
||||||
.catch(console.error)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user