Skip to content

feat: localized unread count#3679

Open
isekovanic wants to merge 6 commits into
developfrom
feat/localized-unread-count
Open

feat: localized unread count#3679
isekovanic wants to merge 6 commits into
developfrom
feat/localized-unread-count

Conversation

@isekovanic

Copy link
Copy Markdown
Contributor

🎯 Goal

SDK followup to this PR: GetStream/stream-chat-js#1787.

All details can be read there.

🛠 Implementation details

🎨 UI Changes

iOS
Before After
Android
Before After

🧪 Testing

☑️ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the develop branch
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios
    • SampleApp iOS and Android
    • Expo iOS and Android

@isekovanic isekovanic requested review from oliverlaz and szuperaz June 29, 2026 11:58
if (client.options.isLocalUnreadCountEnabled) {
channel.markReadLocally();
if (updateChannelUnreadState) {
setChannelUnreadState({ last_read: new Date(), unread_messages: 0 });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason that we set channel unread state here, instead of setting it from WS event like we do for mark.read?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no particularly important reason here, just architecture rationale' I guess.

Local unreads work only for the current user (not for other users obviously). This is sort of mimicking an HTTP response (a successful one) upon which we immediately set the state. We ignore the WS event as we do not need it any longer (nor is there any relevant date jump that we must set from the backend or whatever).

Pretty much the same as consuming:

 const response = await channel.markRead();

and then

if (updateChannelUnreadState && response && lastRead) {
            setChannelUnreadState({
              last_read: lastRead,
              last_read_message_id: response?.event.last_read_message_id,
              unread_messages: 0,
            });
...
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed we do it for markRead too, but wouldn't it be better to return new read info when calling markReadLocally and call setChannelUnreadState with that response? With this, we kind of have two distinct states. For example markReadLocally sets last_read_message_id but we never set this field when calling setChannelUnreadState, I assume it doesn't cause any bugs currently, but may cause issues in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose, perhaps we can do that yeah and try to mimic a response.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants