From 537a237e4a04f18c59d91ca592984e46d99296d2 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 11 Sep 2022 12:52:41 +0200 Subject: fix undefined in localStorage --- client-web/source/preferences/mod.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client-web/source') diff --git a/client-web/source/preferences/mod.ts b/client-web/source/preferences/mod.ts index 08ecaea..f4fa551 100644 --- a/client-web/source/preferences/mod.ts +++ b/client-web/source/preferences/mod.ts @@ -44,7 +44,7 @@ export function register_prefs>>(ds: }) if (!d.allow_url) value = undefined const j = localStorage.getItem(key) - if (j) value ??= JSON.parse(j) + if (j) value ??= JSON.parse(j) ?? undefined if (value !== undefined) explicit[key] = value value ??= d.default; @@ -63,7 +63,7 @@ export function change_pref(key: T, value: typeof else delete PREFS_EXPLICIT[key] pref_change_handlers.get(key)?.forEach(h => h()) // window.location.hash = "#" + generate_section() - localStorage.setItem(key, JSON.stringify(value)) + localStorage.setItem(key, JSON.stringify(value) ?? null) } function param_to_string(p: T): string { -- cgit v1.2.3-70-g09d2