Skip to content

Commit a9e5dff

Browse files
committed
fix: corrupt member response in membership
1 parent 00f8c6a commit a9e5dff

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

package/src/store/apis/upsertChannels.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ChannelAPIResponse } from 'stream-chat';
1+
import type { ChannelAPIResponse, ChannelMemberResponse } from 'stream-chat';
22

33
import { upsertMembers } from './upsertMembers';
44

@@ -32,8 +32,11 @@ export const upsertChannels = async ({
3232
queries.push(createUpsertQuery('channels', mapChannelDataToStorable(channel.channel)));
3333

3434
const { members, membership, messages, read } = channel;
35-
if (membership) {
36-
members.push(membership);
35+
if (
36+
membership &&
37+
!members.includes((m: ChannelMemberResponse) => m.user?.id === membership.user?.id)
38+
) {
39+
members.push({ ...membership, user_id: membership.user?.id });
3740
}
3841
queries = queries.concat(
3942
await upsertMembers({

0 commit comments

Comments
 (0)