Function: hasGroupUnread()
hasGroupUnread(
group,currentUserId?,isCurrentlyViewing?):boolean
Defined in: src/utils/group-utils.ts:106
Determines whether a group has unread messages for a specific user.
Rules:
- If no current user or group has no lastMessageAt, no unread.
- If the user is currently actively viewing this group's chat, no unread.
- If the last message was sent by the user themselves, never mark as unread (prevents self-trigger bug).
- If the user has a memberLastReadAt timestamp, compare it with lastMessageAt.
- If no memberLastReadAt exists (first time), check if lastMessageAt is after their joinedAt timestamp.
Parameters
group
currentUserId?
string | null
isCurrentlyViewing?
boolean = false
Returns
boolean