mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
fix: fixed bugs in downloader (#1342)
This commit is contained in:
@ -22,8 +22,20 @@ export function isEnabled(plugin: string) {
|
||||
return pluginConfig !== undefined && pluginConfig.enabled;
|
||||
}
|
||||
|
||||
export function setOptions<T>(plugin: string, options: T) {
|
||||
/**
|
||||
* Set options for a plugin
|
||||
* @param plugin Plugin name
|
||||
* @param options Options to set
|
||||
* @param exclude Options to exclude from the options object
|
||||
*/
|
||||
export function setOptions<T>(plugin: string, options: T, exclude: string[] = ['enabled']) {
|
||||
const plugins = store.get('plugins') as Record<string, T>;
|
||||
// HACK: This is a workaround for preventing changed options from being overwritten
|
||||
exclude.forEach((key) => {
|
||||
if (Object.prototype.hasOwnProperty.call(options, key)) {
|
||||
delete options[key as keyof T];
|
||||
}
|
||||
});
|
||||
store.set('plugins', {
|
||||
...plugins,
|
||||
[plugin]: {
|
||||
@ -33,8 +45,8 @@ export function setOptions<T>(plugin: string, options: T) {
|
||||
});
|
||||
}
|
||||
|
||||
export function setMenuOptions<T>(plugin: string, options: T) {
|
||||
setOptions(plugin, options);
|
||||
export function setMenuOptions<T>(plugin: string, options: T, exclude: string[] = ['enabled']) {
|
||||
setOptions(plugin, options, exclude);
|
||||
if (store.get('options.restartOnConfigChanges')) {
|
||||
restart();
|
||||
}
|
||||
@ -45,11 +57,11 @@ export function getOptions<T>(plugin: string): T {
|
||||
}
|
||||
|
||||
export function enable(plugin: string) {
|
||||
setMenuOptions(plugin, { enabled: true });
|
||||
setMenuOptions(plugin, { enabled: true }, []);
|
||||
}
|
||||
|
||||
export function disable(plugin: string) {
|
||||
setMenuOptions(plugin, { enabled: false });
|
||||
setMenuOptions(plugin, { enabled: false }, []);
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user