GetStream / stream-chat-js

JS / Browser Client - Build Chat with GetStream.io
https://getstream.io/chat/
Other
178 stars 76 forks source link

fix: align unread counting on muted channel #1265

Closed arnautov-anton closed 5 months ago

arnautov-anton commented 6 months ago

Description of the changes, What, Why and How?

Few weeks ago we received a GH issue where integrator mentions, that muting a channel with unread count > 0 will reset unread count to zero - while that is not the case, the issue they described further still stands and that is when the state gets actually reset (upon unmuting said channel) and the page is reloaded (re-query the channels), the unread count is back where it was prior to muting/unmuting.

This PR removes condition from unread counting function and removes state resetting in the notification.channel_mutes_updated handler. That way when the channel is unmuted the unread count represents actual value which would match the one received from the channel when re-queried.

Circle back once applicable: Adjust unread count behavior for muted channels - whenever muted channel receives a new message, the unread count state should increment. Currently this is not the case and re-querying after unmuting will result in new messages not being counted as unread.

To test:

  1. user A sends message to channel C
  2. user B does not display the channel C and mutes it (/read is not called)
  3. user A sends another message to channel C
  4. user B unmutes channel C and reloads the page (requeries the channels)

Expected count of unread messages for user B on channel C: 2 Actual unread count: 1

Handlers should account for this behaviour during runtime as well and should increase unread count; meaning _countMessageAsUnread should be adjusted as well.

Closes: GetStream/stream-chat-react#2306

TODO

github-actions[bot] commented 6 months ago

Size Change: -560 B (0%)

Total Size: 352 kB

Filename Size Change
dist/browser.es.js 76 kB -132 B (0%)
dist/browser.full-bundle.min.js 46.3 kB -94 B (0%)
dist/browser.js 77 kB -98 B (0%)
dist/index.es.js 76 kB -136 B (0%)
dist/index.js 77 kB -100 B (0%)

compressed-size-action