mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-15 20:31:46 +00:00
feat: use TS private keyword instead of JS private identifier
This commit is contained in:
@ -97,7 +97,7 @@ export class PluginConfig<T extends OneOfDefaultConfigKey> {
|
|||||||
this.config = { ...pluginDefaultConfig, ...pluginConfig };
|
this.config = { ...pluginDefaultConfig, ...pluginConfig };
|
||||||
|
|
||||||
if (this.enableFront) {
|
if (this.enableFront) {
|
||||||
this.#setupFront();
|
this.setupFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
activePlugins[name] = this;
|
activePlugins[name] = this;
|
||||||
@ -109,8 +109,8 @@ export class PluginConfig<T extends OneOfDefaultConfigKey> {
|
|||||||
|
|
||||||
set(key: keyof ConfigType<T>, value: ValueOf<ConfigType<T>>) {
|
set(key: keyof ConfigType<T>, value: ValueOf<ConfigType<T>>) {
|
||||||
this.config[key] = value;
|
this.config[key] = value;
|
||||||
this.#onChange(key);
|
this.onChange(key);
|
||||||
this.#save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll(): ConfigType<T> {
|
getAll(): ConfigType<T> {
|
||||||
@ -126,7 +126,7 @@ export class PluginConfig<T extends OneOfDefaultConfigKey> {
|
|||||||
for (const [key, value] of Object.entries(options) as Entries<typeof options>) {
|
for (const [key, value] of Object.entries(options) as Entries<typeof options>) {
|
||||||
if (this.config[key] !== value) {
|
if (this.config[key] !== value) {
|
||||||
if (value !== undefined) this.config[key] = value;
|
if (value !== undefined) this.config[key] = value;
|
||||||
this.#onChange(key, false);
|
this.onChange(key, false);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ export class PluginConfig<T extends OneOfDefaultConfigKey> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultConfig() {
|
getDefaultConfig() {
|
||||||
@ -152,7 +152,7 @@ export class PluginConfig<T extends OneOfDefaultConfigKey> {
|
|||||||
setAndMaybeRestart(key: keyof ConfigType<T>, value: ValueOf<ConfigType<T>>) {
|
setAndMaybeRestart(key: keyof ConfigType<T>, value: ValueOf<ConfigType<T>>) {
|
||||||
this.config[key] = value;
|
this.config[key] = value;
|
||||||
setMenuOptions(this.name, this.config);
|
setMenuOptions(this.name, this.config);
|
||||||
this.#onChange(key);
|
this.onChange(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribe(valueName: keyof ConfigType<T>, fn: (config: ConfigType<T>) => void) {
|
subscribe(valueName: keyof ConfigType<T>, fn: (config: ConfigType<T>) => void) {
|
||||||
@ -164,11 +164,11 @@ export class PluginConfig<T extends OneOfDefaultConfigKey> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Called only from back */
|
/** Called only from back */
|
||||||
#save() {
|
private save() {
|
||||||
setOptions(this.name, this.config);
|
setOptions(this.name, this.config);
|
||||||
}
|
}
|
||||||
|
|
||||||
#onChange(valueName: keyof ConfigType<T>, single: boolean = true) {
|
private onChange(valueName: keyof ConfigType<T>, single: boolean = true) {
|
||||||
this.subscribers[valueName]?.(this.config[valueName] as ConfigType<T>);
|
this.subscribers[valueName]?.(this.config[valueName] as ConfigType<T>);
|
||||||
if (single) {
|
if (single) {
|
||||||
for (const fn of this.allSubscribers) {
|
for (const fn of this.allSubscribers) {
|
||||||
@ -177,7 +177,7 @@ export class PluginConfig<T extends OneOfDefaultConfigKey> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#setupFront() {
|
private setupFront() {
|
||||||
const ignoredMethods = ['subscribe', 'subscribeAll'];
|
const ignoredMethods = ['subscribe', 'subscribeAll'];
|
||||||
|
|
||||||
if (process.type === 'renderer') {
|
if (process.type === 'renderer') {
|
||||||
|
|||||||
Reference in New Issue
Block a user