aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/Settings.ts8
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);
}