aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/settings.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/api/settings.ts b/src/api/settings.ts
index 0f2356f..a5bda83 100644
--- a/src/api/settings.ts
+++ b/src/api/settings.ts
@@ -46,7 +46,7 @@ function makeProxy(settings: Settings, root = settings, path = ""): Settings {
return new Proxy(settings, {
get(target, p: string) {
const v = target[p];
- if (typeof v === "object" && !Array.isArray(v))
+ if (typeof v === "object" && !Array.isArray(v) && v !== null)
return makeProxy(v, root, `${path}${path && "."}${p}`);
return v;
},
@@ -67,11 +67,17 @@ function makeProxy(settings: Settings, root = settings, path = ""): Settings {
}
/**
+ * Same as {@link Settings} but unproxied. You should treat this as readonly,
+ * as modifying properties on this will not save to disk or call settings
+ * listeners.
+ */
+export const PlainSettings = settings;
+/**
* A smart settings object. Altering props automagically saves
* the updated settings to disk.
+ * This recursively proxies objects. If you need the object non proxied, use {@link PlainSettings}
*/
export const Settings = makeProxy(settings);
-
/**
* Settings hook for React components. Returns a smart settings
* object that automagically triggers a rerender if any properties