fix: Update total notification count only when the 'all' filter is active to prevent incorrect overwrites.

This commit is contained in:
pradeepkumar committed 2026-03-19 16:25:10 +05:30
1 parent 6aa4b62df3
commit 94b7577234
2 files changed
+8 -2

No files matched your search

+5 -1
View File
@@ -49,7 +49,11 @@ export default function AgentNotificationsPage() {
const data = await notificationsApiService.getNotifications(filter, 1, 50); const data = await notificationsApiService.getNotifications(filter, 1, 50);
setNotifications(data.notifications); setNotifications(data.notifications);
setUnreadCount(data.unreadCount); 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) { } catch (err) {
console.error('Failed to fetch notifications:', err); console.error('Failed to fetch notifications:', err);
} finally { } finally {
+3 -1
View File
@@ -47,7 +47,9 @@ export default function UserNotificationsPage() {
const data = await notificationsApiService.getNotifications(filter, 1, 50); const data = await notificationsApiService.getNotifications(filter, 1, 50);
setNotifications(data.notifications); setNotifications(data.notifications);
setUnreadCount(data.unreadCount); setUnreadCount(data.unreadCount);
setTotalCount(data.pagination.total); if (filter === 'all') {
setTotalCount(data.pagination.total);
}
} catch (err) { } catch (err) {
console.error('Failed to fetch notifications:', err); console.error('Failed to fetch notifications:', err);
} finally { } finally {