From e4c60431a89ec5949adb5e1837d8877b31dd0de4 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:53:17 +0100 Subject: [PATCH] Fix notification badge delay 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. --- client/src/stores/notificationsStore.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/src/stores/notificationsStore.ts b/client/src/stores/notificationsStore.ts index 589e9ce04c47..46f85203fbb8 100644 --- a/client/src/stores/notificationsStore.ts +++ b/client/src/stores/notificationsStore.ts @@ -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; @@ -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,