Skip to content

Commit c1ece33

Browse files
committed
perf: do not rerender Channel on poll events
1 parent 13f8872 commit c1ece33

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ const ChannelWithContext = <
679679
VideoThumbnail = VideoThumbnailDefault,
680680
} = props;
681681

682+
console.log('am i really rerendering');
683+
682684
const { thread: threadProps, threadInstance } = threadFromProps;
683685
const StopMessageStreamingButton =
684686
StopMessageStreamingButtonOverride === undefined
@@ -766,7 +768,7 @@ const ChannelWithContext = <
766768
if (shouldSyncChannel) {
767769
// Ignore user.watching.start and user.watching.stop events
768770
const ignorableEvents = ['user.watching.start', 'user.watching.stop'];
769-
if (ignorableEvents.includes(event.type)) return;
771+
if (ignorableEvents.includes(event.type) || event.type.startsWith('poll.')) return;
770772

771773
// If the event is typing.start or typing.stop, set the typing state
772774
const isTypingEvent = event.type === 'typing.start' || event.type === 'typing.stop';
@@ -869,7 +871,7 @@ const ChannelWithContext = <
869871
listener?.unsubscribe();
870872
};
871873
// eslint-disable-next-line react-hooks/exhaustive-deps
872-
}, [channel.cid, messageId, shouldSyncChannel]);
874+
}, [channelId, messageId, shouldSyncChannel]);
873875

874876
// subscribe to channel.deleted event
875877
useEffect(() => {

0 commit comments

Comments
 (0)