Skip to content

Commit

Permalink
Fix notification badge delay
Browse files Browse the repository at this point in the history
The first time we retrieve the notifications list the notifications count badge is not updated until the first status poll is done.
This should update the badge right away the first time and then relay on the status count afterwards.
  • Loading branch information
davelopez committed Jan 24, 2024
1 parent c078220 commit e4c6043
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/src/stores/notificationsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const useNotificationsStore = defineStore("notificationsStore", () => {
loadingNotifications.value = true;
await broadcastsStore.loadBroadcasts();
await loadNotifications();
updateUnreadCount();
} else {
const data = await loadNotificationsStatus(lastNotificationUpdate.value);
totalUnreadCount.value = data.total_unread_count;
Expand Down Expand Up @@ -78,6 +79,10 @@ export const useNotificationsStore = defineStore("notificationsStore", () => {
return updateBatchNotification({ notification_ids: [notification.id], changes });
}

function updateUnreadCount() {
totalUnreadCount.value = notifications.value.filter((n) => !n.seen_time).length;
}

return {
notifications,
totalUnreadCount,
Expand Down

0 comments on commit e4c6043

Please sign in to comment.