Skip to content

Commit

Permalink
fix: listen to correct channel read events
Browse files Browse the repository at this point in the history
  • Loading branch information
isekovanic committed Nov 19, 2024
1 parent fc9b908 commit 5a58a65
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ export const useChannelPreviewData = <
const channelLastMessage = channel.lastMessage();
const channelLastMessageString = `${channelLastMessage?.id}${channelLastMessage?.updated_at}`;

useEffect(() => {
const { unsubscribe } = client.on('notification.mark_read', () => {
setUnread(channel.countUnread());
});
return unsubscribe;
}, [channel, client]);

useEffect(() => {
if (
channelLastMessage &&
Expand All @@ -56,7 +63,7 @@ export const useChannelPreviewData = <
setForceUpdate((prev) => prev + 1);
}
};
const { unsubscribe } = client.on('notification.mark_read', handleReadEvent);
const { unsubscribe } = client.on('message.read', handleReadEvent);
return unsubscribe;
}, [client, channel]);

Expand Down

0 comments on commit 5a58a65

Please sign in to comment.