stream-chat-android
stream-chat-android copied to clipboard
[ISSUE-4060] Fixing unread count when syncing at the same time
🎯 Goal
Fix unread count when SDK is syncing at the same time
🛠 Implementation details
1 - Buffering events when requesting channels This is necessary because this is the moment when we will know the information about the SDK, for example, we will know the unread count of a channel.
Counting the unread messages before syncing with the backend makes no sense as we would wrongly assume that it is zero. Trusting the database is not a good idea also, because we have no guarantee that we have all messages loaded in the database, we could have 100+ unread messages, but have loaded only 30 messages of the channel.
2 - Increasing the unread count only when the message is not already in the state. If the message is already in the SDK, it means that the count was already done (by the sync). Counting it again would create a wrong offset in it.
🎨 UI Changes
Before | After |
---|---|
🧪 Testing
As the video shows, right after start the sample app, send a storm of messages and check that the unread count of the summed channels is equal to the unread count of the backend (that little icon in the bottom left of the sample app asserts that)
☑️Contributor Checklist
General
- [x] I have signed the Stream CLA (required)
- [x] Assigned a person / code owner group (required)
- [ ] Thread with the PR link started in a respective Slack channel (#android-chat-core or #android-chat-ui) (required)
- [x] PR targets the
develop
branch - [x] PR is linked to the GitHub issue it resolves
Code & documentation
- [ ] Changelog is updated with client-facing changes
- [x] New code is covered by unit tests
- [x] Comparison screenshots added for visual changes
- [x] Affected documentation updated (KDocs, docusaurus, tutorial)
☑️Reviewer Checklist
- [ ] UI Components sample runs & works
- [ ] Compose sample runs & works
- [ ] UI Changes correct (before & after images)
- [ ] Bugs validated (bugfixes)
- [ ] New feature tested and works
- [ ] Release notes and docs clearly describe changes
- [ ] All code we touched has new or updated KDocs
🎉 GIF
RIght? Right??
This PR needs further discussion. Converting to draft for now