Skip to content

Commit 0434848

Browse files
committed
fix: use proper unreadCount
1 parent 9ca4c35 commit 0434848

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

package/src/components/Chat/hooks/handleEventToSyncDB.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,17 @@ export const handleEventToSyncDB = async <
130130
});
131131
if (cid && client.user && client.user.id !== user?.id) {
132132
const userId = client.user.id;
133-
const ownReads = client.activeChannels[cid]?.state.read[userId];
133+
const channel = client.activeChannels[cid];
134+
const ownReads = channel?.state.read[userId];
135+
const unreadCount = channel?.state.unreadCount;
134136
const upsertReadsQueries = await upsertReads({
135137
cid,
136138
flush: flushOverride,
137139
reads: [
138140
{
139141
last_read: ownReads.last_read.toString() as string,
140142
last_read_message_id: ownReads.last_read_message_id,
141-
unread_messages: ownReads?.unread_messages,
143+
unread_messages: unreadCount,
142144
user: client.user,
143145
},
144146
],

0 commit comments

Comments
 (0)