mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
lint
This commit is contained in:
@ -32,7 +32,7 @@ function registerShortcuts(win, options) {
|
||||
_registerLocalShortcut(win, "CommandOrControl+L", search);
|
||||
|
||||
const { global, local } = options;
|
||||
const shortcutOptions = {global, local};
|
||||
const shortcutOptions = { global, local };
|
||||
|
||||
for (const optionType in shortcutOptions) {
|
||||
registerAllShortcuts(shortcutOptions[optionType], optionType);
|
||||
@ -41,23 +41,25 @@ function registerShortcuts(win, options) {
|
||||
function registerAllShortcuts(container, type) {
|
||||
for (const action in container) {
|
||||
if (!container[action]) {
|
||||
continue; //accelerator is empty
|
||||
continue; // Action accelerator is empty
|
||||
}
|
||||
|
||||
|
||||
console.debug(`Registering ${type} shortcut`, container[action], ":", action);
|
||||
if (!songControls[action]) {
|
||||
console.warn("Invalid action", action);
|
||||
continue;
|
||||
}
|
||||
|
||||
type === "global" ?
|
||||
_registerGlobalShortcut(win.webContents, container[action], songControls[action]) :
|
||||
_registerLocalShortcut(win, local[action], songControls[action]);
|
||||
|
||||
if (type === "global") {
|
||||
_registerGlobalShortcut(win.webContents, container[action], songControls[action]);
|
||||
} else { // type === "local"
|
||||
_registerLocalShortcut(win, local[action], songControls[action]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Update options to new format */
|
||||
/** Update options to new format if they are still an array (old format) */
|
||||
function updateOptions(options) {
|
||||
let updated = false;
|
||||
for (const optionType of ["global", "local"]) {
|
||||
|
||||
@ -25,16 +25,17 @@ function setOption(options, key = null, newValue = null) {
|
||||
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");
|
||||
// Helper function for keybind prompt
|
||||
const kb = (label_, value_, default_) => { return { value: value_, label: label_, default: default_ }; };
|
||||
|
||||
function promptKeybind(options, win) {
|
||||
let promptOptions = {
|
||||
const promptOptions = {
|
||||
title: "Global Keybinds",
|
||||
icon: iconPath,
|
||||
label: "Choose Global Keybinds for Songs Control:",
|
||||
type: "keybind",
|
||||
keybindOptions: [
|
||||
keybindOptions: [ // If default=undefined then no default is used
|
||||
kb("Previous", "previous", options.global?.previous),
|
||||
kb("Play / Pause", "playPause", options.global?.playPause),
|
||||
kb("Next", "next", options.global?.next)
|
||||
|
||||
Reference in New Issue
Block a user