diff options
author | megumin <megumin.bakaretsurie@gmail.com> | 2023-08-04 18:52:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-04 19:52:20 +0200 |
commit | d6c43986fd665b60a8a83d41ef907dab22e990e7 (patch) | |
tree | ff9eda6794ef371568662b389a5e71e32bbbc16c /src/api | |
parent | bb7deeb09cb263d158de0d99e873c3d3f43a73bb (diff) | |
download | Vencord-d6c43986fd665b60a8a83d41ef907dab22e990e7.tar.gz Vencord-d6c43986fd665b60a8a83d41ef907dab22e990e7.tar.bz2 Vencord-d6c43986fd665b60a8a83d41ef907dab22e990e7.zip |
Add proper user-friendly theme manager (#635)
Co-authored-by: Justice Almanzar <superdash993@gmail.com>
Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
Co-authored-by: V <vendicated@riseup.net>
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/Settings.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/api/Settings.ts b/src/api/Settings.ts index 709050f..c380f63 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -34,6 +34,7 @@ export interface Settings { useQuickCss: boolean; enableReactDevtools: boolean; themeLinks: string[]; + enabledThemes: string[]; frameless: boolean; transparent: boolean; winCtrlQ: boolean; @@ -68,6 +69,7 @@ const DefaultSettings: Settings = { autoUpdateNotification: true, useQuickCss: true, themeLinks: [], + enabledThemes: [], enableReactDevtools: false, frameless: false, transparent: false, @@ -107,7 +109,7 @@ const saveSettingsOnFrequentAction = debounce(async () => { } }, 60_000); -type SubscriptionCallback = ((newValue: any, path: string) => void) & { _path?: string; }; +type SubscriptionCallback = ((newValue: any, path: string) => void) & { _paths?: Array<string>; }; const subscriptions = new Set<SubscriptionCallback>(); const proxyCache = {} as Record<string, any>; @@ -164,7 +166,7 @@ function makeProxy(settings: any, root = settings, path = ""): Settings { const setPath = `${path}${path && "."}${p}`; delete proxyCache[setPath]; for (const subscription of subscriptions) { - if (!subscription._path || subscription._path === setPath) { + if (!subscription._paths || subscription._paths.includes(setPath)) { subscription(v, setPath); } } @@ -235,7 +237,7 @@ type ResolvePropDeep<T, P> = P extends "" ? T : export function addSettingsListener<Path extends keyof Settings>(path: Path, onUpdate: (newValue: Settings[Path], path: Path) => void): void; export function addSettingsListener<Path extends string>(path: Path, onUpdate: (newValue: Path extends "" ? any : ResolvePropDeep<Settings, Path>, path: Path extends "" ? string : Path) => void): void; export function addSettingsListener(path: string, onUpdate: (newValue: any, path: string) => void) { - (onUpdate as SubscriptionCallback)._path = path; + ((onUpdate as SubscriptionCallback)._paths ??= []).push(path); subscriptions.add(onUpdate); } |