Category: Feature / Bug Fix
Difficulty: High
Description
markAsRead in MessageContext.tsx is a no-op — the function body is empty. As a result, unread message counts never decrement and the red badge on the navigation never clears even after reading a conversation.
Problem Statement
// MessageContext.tsx — line ~120
const markAsRead = (_threadId: string) => {
// Logic to clear unread count
};
Additionally, unreadCount on Thread is only incremented during sendMessage but is never set accurately for the receiving user because both users share the same localStorage key.
Technical Requirements
- Implement
markAsRead to set unreadCount = 0 for the given thread and persist to localStorage
- Fix unread count logic: when
sendMessage is called, increment unreadCount only for participants who are NOT the sender
setActiveThreadId should automatically call markAsRead for the newly active thread
- The
BottomNav and NotificationDropdown message badge must reactively update when unread count changes
- Add a
totalUnreadMessages derived value to the context
Acceptance Criteria
Deliverables
- Updated
MessageContext.tsx
- Updated
Navigation.tsx (Sidebar and BottomNav badge logic)
Category: Feature / Bug Fix
Difficulty: High
Description
markAsReadinMessageContext.tsxis a no-op — the function body is empty. As a result, unread message counts never decrement and the red badge on the navigation never clears even after reading a conversation.Problem Statement
Additionally,
unreadCountonThreadis only incremented duringsendMessagebut is never set accurately for the receiving user because both users share the same localStorage key.Technical Requirements
markAsReadto setunreadCount = 0for the given thread and persist to localStoragesendMessageis called, incrementunreadCountonly for participants who are NOT the sendersetActiveThreadIdshould automatically callmarkAsReadfor the newly active threadBottomNavandNotificationDropdownmessage badge must reactively update when unread count changestotalUnreadMessagesderived value to the contextAcceptance Criteria
totalUnreadMessagesis exported from context and consumed byNavigation.tsxDeliverables
MessageContext.tsxNavigation.tsx(Sidebar and BottomNav badge logic)