mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 03:11:46 +00:00
feat: run prettier
This commit is contained in:
@ -7,33 +7,49 @@ import type { BrowserWindow } from 'electron';
|
||||
import type { MenuContext } from '@/types/contexts';
|
||||
import type { MenuTemplate } from '@/menu';
|
||||
|
||||
export const onMenu = async ({ window, getConfig, setConfig }: MenuContext<ShortcutsPluginConfig>): Promise<MenuTemplate> => {
|
||||
export const onMenu = async ({
|
||||
window,
|
||||
getConfig,
|
||||
setConfig,
|
||||
}: MenuContext<ShortcutsPluginConfig>): Promise<MenuTemplate> => {
|
||||
const config = await getConfig();
|
||||
|
||||
/**
|
||||
* Helper function for keybind prompt
|
||||
*/
|
||||
const kb = (label_: string, value_: string, default_?: string): KeybindOptions => ({ value: value_, label: label_, default: default_ });
|
||||
const kb = (
|
||||
label_: string,
|
||||
value_: string,
|
||||
default_?: string,
|
||||
): KeybindOptions => ({ value: value_, label: label_, default: default_ });
|
||||
|
||||
async function promptKeybind(config: ShortcutsPluginConfig, win: BrowserWindow) {
|
||||
const output = await prompt({
|
||||
title: 'Global Keybinds',
|
||||
label: 'Choose Global Keybinds for Songs Control:',
|
||||
type: 'keybind',
|
||||
keybindOptions: [ // If default=undefined then no default is used
|
||||
kb('Previous', 'previous', config.global?.previous),
|
||||
kb('Play / Pause', 'playPause', config.global?.playPause),
|
||||
kb('Next', 'next', config.global?.next),
|
||||
],
|
||||
height: 270,
|
||||
...promptOptions(),
|
||||
}, win);
|
||||
async function promptKeybind(
|
||||
config: ShortcutsPluginConfig,
|
||||
win: BrowserWindow,
|
||||
) {
|
||||
const output = await prompt(
|
||||
{
|
||||
title: 'Global Keybinds',
|
||||
label: 'Choose Global Keybinds for Songs Control:',
|
||||
type: 'keybind',
|
||||
keybindOptions: [
|
||||
// If default=undefined then no default is used
|
||||
kb('Previous', 'previous', config.global?.previous),
|
||||
kb('Play / Pause', 'playPause', config.global?.playPause),
|
||||
kb('Next', 'next', config.global?.next),
|
||||
],
|
||||
height: 270,
|
||||
...promptOptions(),
|
||||
},
|
||||
win,
|
||||
);
|
||||
|
||||
if (output) {
|
||||
const newConfig = { ...config };
|
||||
|
||||
for (const { value, accelerator } of output) {
|
||||
newConfig.global[value as keyof ShortcutsPluginConfig['global']] = accelerator;
|
||||
newConfig.global[value as keyof ShortcutsPluginConfig['global']] =
|
||||
accelerator;
|
||||
}
|
||||
|
||||
setConfig(config);
|
||||
|
||||
Reference in New Issue
Block a user