Skip to content

Commit

Permalink
Merge pull request #1476 from appwrite/fix-prefs-nullpointer
Browse files Browse the repository at this point in the history
Fix prefs nullpointer
  • Loading branch information
ArmanNik authored Oct 28, 2024
2 parents f98f7b7 + 6539ad3 commit 520df0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/helpers/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export type NotificationCoolOffOptions = {
exponentialBackoffFactor?: number;
};

const userPreferences = () => get(user).prefs;
const userPreferences = () => get(user)?.prefs;

const notificationPrefs = (): Record<string, NotificationPrefItem> => {
const prefs = userPreferences();
// 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 && Array.isArray(prefs.notificationPrefs) ? {} : prefs.notificationPrefs || {};
};

function updateNotificationPrefs(parsedPrefs: Record<string, NotificationPrefItem>) {
Expand Down

0 comments on commit 520df0a

Please sign in to comment.