Skip to content

Implement markAsRead in MessageContext and add unread badge persistence #3

Description

@Benalex8797

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

  • Opening a thread clears its unread badge immediately
  • Badge count on nav icons is accurate across navigation
  • After page refresh, read state persists correctly
  • totalUnreadMessages is exported from context and consumed by Navigation.tsx

Deliverables

  • Updated MessageContext.tsx
  • Updated Navigation.tsx (Sidebar and BottomNav badge logic)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignThird CampaignCampaign: Third Campaign

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions