Skip to content

feat: add channel state reactive stores#1699

Open
MartinCupela wants to merge 3 commits intomasterfrom
feat/add-channel-state-reactive-stores
Open

feat: add channel state reactive stores#1699
MartinCupela wants to merge 3 commits intomasterfrom
feat/add-channel-state-reactive-stores

Conversation

@MartinCupela
Copy link
Contributor

@MartinCupela MartinCupela commented Mar 10, 2026

Description

Adds reactive display state to channels and threads so UIs across different SDKs can subscribe to display name (and image) updates instead of maintain separate potentially diverging implementations.

It also allows creating a Thread with only a channel and parent message (no threadData) and standardizes thread display name to custom → channel display name.

Channel

1. ChannelState – reactive display store

  • Channel state now exposes a display store (e.g. displayStore) holding displayName and displayImage.
  • Display values are kept in sync when channel/members/custom data change.
  • Consumers (e.g. React SDK) can subscribe to this store and re-render when display name/image changes, instead of using one-off helpers like getDisplayTitle.
Returns the display name for a channel using the following fallback chain:
1. Result of `customDisplayNameGenerator` (if set on this instance)
2. The channel's `name` custom data property
3. For DM channels (exactly 2 members): the other member's name, then "Direct Message"
4. For group channels (3+ members): comma-separated list of 2 other members' names. No ellipsis.
5. `null` if none of the above produced a value

2. ChannelState - convert static properties into backwards compatible reactive stores
As we are adding reactive display store, we have opportunity to add stores for other ChannelState properties.

  • membersStore{ members: Record<string, ChannelMemberResponse>; memberCount: number }
    Member list and count. Updated when members are hydrated or member events are applied.
  • readStore{ read: ChannelReadStatus }
    Per-user read state (last read, unread counts, etc.). Updated from read events and channel sync.
  • typingStore{ typing: Record<string, Event> }
    Active typing indicators by user. Updated from typing.start / typing.stop (and similar) events.
  • watcherStore{ watchers: Record<string, UserResponse>; watcherCount: number }
    Current watchers and count. Updated when watcher presence events are applied.
  • ownCapabilitiesStore{ ownCapabilities: string[] }
    Current user’s capabilities in this channel. Updated when membership/capabilities are synced from channel data or events. Sync over WS is current not supported from the server-side, but may be in the future.
  • mutedUsersStore { mutedUsers: UserResponse[] }
    Users muted in the channel. Updated when mute state is synced or changed.

Thread

1. Constructor with optional data

  • Optional threadData: Thread can be constructed with only channel and parentMessage (no threadData), for “open thread from channel” flows.

2. New displayName property in ThreadState

  • New property displayName on ThreadState: Thread state includes a reactive displayName derived from: (1) custom display name generator, (2) channel display name.
  • Added for parity with Channel. Also there is a title property on ThreadResponse type and so it may be desirable in the future customize the logic to include this property to derive the display name. Also name could be derived from participants names, etc.
Returns the display name for thread using the following fallback chain:
1. Result of `customDisplayNameGenerator` (if set on this instance)
2. The channel's display name (from channel display store)
3. `null` if none of the above produced a value

@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

Size Change: +5.84 kB (+1.6%)

Total Size: 370 kB

Filename Size Change
dist/cjs/index.browser.js 123 kB +1.94 kB (+1.6%)
dist/cjs/index.node.js 125 kB +1.94 kB (+1.58%)
dist/esm/index.mjs 123 kB +1.95 kB (+1.62%)

compressed-size-action

@MartinCupela MartinCupela changed the title Feat/add channel state reactive stores feat: add channel state reactive stores Mar 10, 2026
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.

1 participant