Skip to content

fix: notify channel state subscribers on watcher, ban and member removal events - #1977

Merged
MartinCupela merged 3 commits into
release-v10from
fix/channel-state-in-place-updates
Nov 2, 2026
Merged

MartinCupela merged 3 commits into
release-v10from
fix/channel-state-in-place-updates

Conversation

@MartinCupela

Copy link
Copy Markdown
Contributor

CLA

  • I have signed the Stream CLA (required).
  • Code changes are tested

Description of the changes, What, Why and How?

Linear: REACT-1324

What: some channel events changed channel.state without notifying subscribers, so the UI didn't update.

Why: these handlers wrote into the watchers / members objects already held in the store. A subscriber that compares by reference (useStateStore(channel.state, (s) => ({ watchers: s.watchers }))) saw the same object and did not re-render. This is why the channel-list row's Unblock label does not update (REACT-1268).

How: each handler now assigns a new object:

  • user.watching.start / user.updated / user.watching.stop: a new watchers object. A stop for a user who isn't watching publishes nothing.
  • user.banned / user.unbanned: a new members object. The two branches are merged into one.
  • _initializeState: query-loaded watchers are merged into a new object and published once. An empty list publishes nothing.
  • member.removed for the current user now resets membership to {}, the value it starts with. Before, it kept the removed membership.

The #watchers-members-in-place item in ai-docs/v10-followups.md is marked solved.

Not changed here (already there before this PR):

  • After the user is removed while offline, reloading the channel doesn't clear membership.
  • Banning the current user updates members[me] but not membership.banned.
  • Banning a user who isn't a loaded member adds a partial member entry.

Tests: new tests in test/unit/channel.test.js check both the new value and whether subscribers were notified. Without the fix, the watcher, ban, query and membership tests fail.

Changelog

  • Fixed watcher, ban and member-removal events not notifying channel.state subscribers, and member.removed keeping the current user's membership.

…val events

Watcher events (user.watching.start/stop, user.updated), ban events
(user.banned/unbanned) and the watchers loaded by a channel query wrote
into the current watchers/members objects, so subscribers comparing by
reference never saw the change. They now publish new objects.

member.removed for the current user now also resets membership.

Refs REACT-1324
@MartinCupela
MartinCupela requested review from isekovanic and oliverlaz and removed request for isekovanic November 2, 2026 09:56
Comment thread src/channel.ts Resolved

@isekovanic isekovanic left a comment

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.

lgtm, have a look at the comment if you have the time (more a question than a complaint about something)

The spec documents event.user on member.removed as the user who removed
the member, so the removed user's id now comes from event.member and
falls back to event.user.

Refs REACT-1324
@MartinCupela
MartinCupela merged commit 3a7be78 into release-v10 Nov 2, 2026
4 checks passed
@MartinCupela
MartinCupela deleted the fix/channel-state-in-place-updates branch November 2, 2026 12:16
github-actions Bot pushed a commit that referenced this pull request Nov 2, 2026
## [10.0.0-rc.30](v10.0.0-rc.29...v10.0.0-rc.30) (2026-11-02)

### Bug Fixes

* handle user.updated in threads ([#1979](#1979)) ([9064ffc](9064ffc))
* notify channel state subscribers on watcher, ban and member removal events ([#1977](#1977)) ([3a7be78](3a7be78))
* optimistic updates for translated messages ([#1975](#1975)) ([91fc290](91fc290))
* restore composer custom data from drafts and edits, keep custom on edit ([#1978](#1978)) ([51ddcad](51ddcad))
* unread snapshot count, pinned replies, joined and invite filters, read events check ([#1981](#1981)) ([1247d10](1247d10))
@stream-ci-bot

Copy link
Copy Markdown

🎉 This PR is included in version 10.0.0-rc.30 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants