From 81af03fa839d995aa14ba17733d021ea5615cd0c Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 15 Nov 2024 19:50:24 +0100 Subject: [PATCH] style: improve null handling --- src/lib/helpers/notifications.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/helpers/notifications.ts b/src/lib/helpers/notifications.ts index 114980389..c0cb819f9 100644 --- a/src/lib/helpers/notifications.ts +++ b/src/lib/helpers/notifications.ts @@ -19,12 +19,12 @@ const userPreferences = () => get(user)?.prefs; const notificationPrefs = (): Record => { const prefs = userPreferences(); - if (prefs === null) { + // due to php backend, empty object can be returnd as an empty array + if (prefs?.notificationPrefs === null || Array.isArray(prefs?.notificationPrefs)) { return {}; } - // for some reason, the prefs become array as default or on all clear. let's reset. - return Array.isArray(prefs?.notificationPrefs) ? {} : (prefs?.notificationPrefs ?? {}); + return prefs.notificationPrefs; }; function updateNotificationPrefs(parsedPrefs: Record) {