Skip to content

Conversation

@andremion
Copy link
Contributor

@andremion andremion commented Nov 4, 2025

🎯 Goal

Problem

After logout/login, reopening a chat where a message was sent offline shows an unread label even when all "unread" messages are from the current user.

🛠 Implementation details

Root Cause

When lastReadMessageId is not found in the messages list (can happen after logout/login when read state is out of sync), calculateUnreadLabel treated all messages as unread without checking if they're from the current user. The user's own messages were incorrectly marked as unread.

Solution

Added a check in UnreadLabelCalculator.calculateUnreadLabel() when lastReadMessage == null:
If all unread messages are from the current user, return null (no unread label)

🎨 UI Changes

Before After
Screen_recording_20251104_134835.webm
Screen_recording_20251104_135705.webm

🧪 Testing

  • Open a chat with no network connection
  • Send a message
  • Return to the chat list
  • Restore network connection
  • Log out (clear chats history)
  • Log back in
  • Reopen the same chat

Expected: No unread label should be displayed (user has already seen their own messages)
Actual: Unread label is incorrectly displayed

The unread indicator will no longer be displayed when all unread messages belong to the current user, which can happen after logging out and back in. This is achieved by checking message ownership even when the last-read message is not present in the loaded message list.
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 3.23 MB 3.23 MB 0.00 MB 🟢
stream-chat-android-offline 3.45 MB 3.45 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.54 MB 10.54 MB 0.00 MB 🟢
stream-chat-android-compose 12.76 MB 12.76 MB 0.00 MB 🟢

@andremion andremion marked this pull request as ready for review November 4, 2025 14:05
@andremion andremion requested a review from a team as a code owner November 4, 2025 14:05
@VelikovPetar VelikovPetar enabled auto-merge (squash) November 4, 2025 16:44
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 4, 2025

@VelikovPetar VelikovPetar merged commit abf7333 into develop Nov 4, 2025
13 checks passed
@VelikovPetar VelikovPetar deleted the AND-890-unread-label-issue branch November 4, 2025 17:00
@andremion andremion added bug Something isn't working compose Jetpack Compose ui-components labels Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compose Jetpack Compose ui-components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants