diff options
author | metamuffin <metamuffin@disroot.org> | 2022-09-11 12:52:41 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-09-11 12:52:41 +0200 |
commit | 537a237e4a04f18c59d91ca592984e46d99296d2 (patch) | |
tree | 79b8c7a2206c5626030d8243839471ac30cda642 /client-web/source | |
parent | e576676d65efbd019f58a620db2cd499defb80f2 (diff) | |
download | keks-meet-537a237e4a04f18c59d91ca592984e46d99296d2.tar keks-meet-537a237e4a04f18c59d91ca592984e46d99296d2.tar.bz2 keks-meet-537a237e4a04f18c59d91ca592984e46d99296d2.tar.zst |
fix undefined in localStorage
Diffstat (limited to 'client-web/source')
-rw-r--r-- | client-web/source/preferences/mod.ts | 4 |
1 files changed, 2 insertions, 2 deletions
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<T extends Record<string, PrefDecl<unknown>>>(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<T extends keyof typeof PREFS>(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<T>(p: T): string { |