Skip to content

Commit 5a58a65

Browse files
committed
fix: listen to correct channel read events
1 parent fc9b908 commit 5a58a65

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ export const useChannelPreviewData = <
3030
const channelLastMessage = channel.lastMessage();
3131
const channelLastMessageString = `${channelLastMessage?.id}${channelLastMessage?.updated_at}`;
3232

33+
useEffect(() => {
34+
const { unsubscribe } = client.on('notification.mark_read', () => {
35+
setUnread(channel.countUnread());
36+
});
37+
return unsubscribe;
38+
}, [channel, client]);
39+
3340
useEffect(() => {
3441
if (
3542
channelLastMessage &&
@@ -56,7 +63,7 @@ export const useChannelPreviewData = <
5663
setForceUpdate((prev) => prev + 1);
5764
}
5865
};
59-
const { unsubscribe } = client.on('notification.mark_read', handleReadEvent);
66+
const { unsubscribe } = client.on('message.read', handleReadEvent);
6067
return unsubscribe;
6168
}, [client, channel]);
6269

0 commit comments

Comments
 (0)