Skip to content

Commit eb86009

Browse files
authored
fix: use channel.cid instead of id (#2960)
* fix: use channel.cid instead of id * chore: remove console.log * chore: restructure ignored events * chore: add better explanatino
1 parent 51893bb commit eb86009

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,17 @@ const ChannelWithContext = <
766766

767767
const handleEvent: EventHandler<StreamChatGenerics> = (event) => {
768768
if (shouldSyncChannel) {
769-
// Ignore user.watching.start and user.watching.stop events
770-
const ignorableEvents = ['user.watching.start', 'user.watching.stop'];
771-
if (ignorableEvents.includes(event.type) || event.type.startsWith('poll.')) return;
769+
/**
770+
* Ignore user.watching.start and user.watching.stop as we should not copy the entire state when
771+
* they occur. Also ignore all poll related events since they're being handled in their own
772+
* reactive state and have no business having an effect on the Channel component.
773+
*/
774+
if (
775+
event.type.startsWith('poll.') ||
776+
event.type === 'user.watching.start' ||
777+
event.type === 'user.watching.stop'
778+
)
779+
return;
772780

773781
// If the event is typing.start or typing.stop, set the typing state
774782
const isTypingEvent = event.type === 'typing.start' || event.type === 'typing.stop';
@@ -871,7 +879,7 @@ const ChannelWithContext = <
871879
listener?.unsubscribe();
872880
};
873881
// eslint-disable-next-line react-hooks/exhaustive-deps
874-
}, [channelId, messageId, shouldSyncChannel]);
882+
}, [channel.cid, messageId, shouldSyncChannel]);
875883

876884
// subscribe to channel.deleted event
877885
useEffect(() => {

0 commit comments

Comments
 (0)