From 94b7577234f801724a3fac4aebd90311acc73606 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Thu, 19 Mar 2026 16:25:10 +0530 Subject: [PATCH] fix: Update total notification count only when the 'all' filter is active to prevent incorrect overwrites. --- src/app/(agent)/agent/notifications/page.tsx | 6 +++++- src/app/(user)/user/notifications/page.tsx | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/(agent)/agent/notifications/page.tsx b/src/app/(agent)/agent/notifications/page.tsx index b8825bc..2dcff69 100644 --- a/src/app/(agent)/agent/notifications/page.tsx +++ b/src/app/(agent)/agent/notifications/page.tsx @@ -49,7 +49,11 @@ export default function AgentNotificationsPage() { const data = await notificationsApiService.getNotifications(filter, 1, 50); setNotifications(data.notifications); setUnreadCount(data.unreadCount); - setTotalCount(data.pagination.total); + // Only update totalCount from the 'all' filter, otherwise it gets overwritten + // with the unread count when switching tabs + if (filter === 'all') { + setTotalCount(data.pagination.total); + } } catch (err) { console.error('Failed to fetch notifications:', err); } finally { diff --git a/src/app/(user)/user/notifications/page.tsx b/src/app/(user)/user/notifications/page.tsx index 9a648b7..2321d6f 100644 --- a/src/app/(user)/user/notifications/page.tsx +++ b/src/app/(user)/user/notifications/page.tsx @@ -47,7 +47,9 @@ export default function UserNotificationsPage() { const data = await notificationsApiService.getNotifications(filter, 1, 50); setNotifications(data.notifications); setUnreadCount(data.unreadCount); - setTotalCount(data.pagination.total); + if (filter === 'all') { + setTotalCount(data.pagination.total); + } } catch (err) { console.error('Failed to fetch notifications:', err); } finally {