Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: align unread counting on muted channel #1265

Merged
merged 2 commits into from Mar 28, 2024

Conversation

arnautov-anton
Copy link
Contributor

@arnautov-anton arnautov-anton commented Mar 15, 2024

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

  • add tests

Copy link
Contributor

github-actions bot commented Mar 15, 2024

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

@arnautov-anton arnautov-anton merged commit 1f1934b into master Mar 28, 2024
7 checks passed
@arnautov-anton arnautov-anton deleted the fix/unread-count-after-unmute branch March 28, 2024 12:58
@github-actions github-actions bot mentioned this pull request Mar 28, 2024
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.

bug: unread on ChannelPreview not updating after muting & unmuting a channel
2 participants