Merge pull request #1481 from appwrite/fix-prefs-null-pointer

Improve prefs nullpointer fix
This commit is contained in:
Steven Nguyen authored and GitHub committed 2024-10-29 17:33:56 -07:00
commit b1ea3ea722
1 file changed
+6 -1
+6 -1
View File
@@ -18,8 +18,13 @@ const userPreferences = () => get(user)?.prefs;
const notificationPrefs = (): Record<string, NotificationPrefItem> => {
const prefs = userPreferences();
if (prefs === null) {
return {};
}
// for some reason, the prefs become array as default or on all clear. let's reset.
return prefs && Array.isArray(prefs.notificationPrefs) ? {} : prefs.notificationPrefs || {};
return Array.isArray(prefs.notificationPrefs) ? {} : prefs.notificationPrefs || {};
};
function updateNotificationPrefs(parsedPrefs: Record<string, NotificationPrefItem>) {