You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## CLA
- [ ] I have signed the [Stream
CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform)
(required).
- [ ] Code changes are tested
## Description of the changes, What, Why and How?
Spec:
https://stream-wiki.notion.site/Local-Unread-Count-specification-38b6a5d7f9f68073a5e1c73298fe0d71
Adds an optin, client side unread count for channels that have read
events disabled (e.g. livestreams). Those channels normally don't track
unread at all and so `_countMessageAsUnread` bails out whenever
`own_capabilities` lacks `read-events`, so integrators have no "N new
messages" affordance to show while scrolled up.
With the new `isLocalUnreadCountEnabled` client option (default
`false`), the SDK maintains a purely local unread count for those
channels. It increments on incoming messages and is reset via the new
`channel.markReadLocally()` method, which dispatches a client only
`message.local_read` event. That event reuses the exact `message.read`
state logic in `_handleChannelEvent` (so read state updates stay in one
place) but skips `syncDeliveredCandidates()`, so the count is never sent
to the backend. `hasReadEvents()` centralizes the capability check.
When offline support is enabled, the local read/unread state is
persisted for channels with disabled `read-events` so the count survives
a cold start. The offline DB handles `message.local_read` (guarded so it
can only affect channels with disabled `read-events` channels with the
option on) and falls back gracefully when `state.read[userId]` is
absent, since the server never sends a read for these channels.
Behavior is fully gated behind the flag, so default off means no change
for existing integrations.
## Changelog
- Add `isLocalUnreadCountEnabled` client option for a client side unread
count on channels with disabled `read-events` (e.g. livestreams)
- Add `Channel.markReadLocally()` to reset the local unread count with
no backend call
- Add `Channel.hasReadEvents()` helper
- Add client only `message.local_read` event
- Persist local unread state to the offline DB so it survives app
restarts
0 commit comments