stream-chat
Advanced tools
Comparing version 8.45.2 to 8.45.3
@@ -607,5 +607,14 @@ /// <reference types="node" /> | ||
_extendEventWithOwnReactions(event: Event<StreamChatGenerics>): void; | ||
_hydrateMembers(members: ChannelMemberResponse<StreamChatGenerics>[]): void; | ||
_hydrateMembers({ members, overrideCurrentState, }: { | ||
members: ChannelMemberResponse<StreamChatGenerics>[]; | ||
/** | ||
* If set to `true` then `ChannelState.members` will be overriden with the newly | ||
* provided `members`, setting this property to `false` will merge current `ChannelState.members` | ||
* object with the newly provided `members` | ||
* (new members with the same `userId` will replace the old ones). | ||
*/ | ||
overrideCurrentState?: boolean; | ||
}): void; | ||
_disconnect(): void; | ||
} | ||
//# sourceMappingURL=channel.d.ts.map |
{ | ||
"name": "stream-chat", | ||
"version": "8.45.2", | ||
"version": "8.45.3", | ||
"description": "JS SDK for the Stream Chat API", | ||
@@ -5,0 +5,0 @@ "author": "GetStream", |
@@ -1664,4 +1664,6 @@ import { ChannelState } from './channel_state'; | ||
// add the Users | ||
// add the members and users | ||
if (state.members) { | ||
this._hydrateMembers({ members: state.members }); | ||
for (const member of state.members) { | ||
@@ -1732,6 +1734,2 @@ if (member.user) { | ||
if (state.members) { | ||
this._hydrateMembers(state.members); | ||
} | ||
return { | ||
@@ -1752,9 +1750,30 @@ messageSet, | ||
_hydrateMembers(members: ChannelMemberResponse<StreamChatGenerics>[]) { | ||
this.state.members = members.reduce((acc, member) => { | ||
_hydrateMembers({ | ||
members, | ||
overrideCurrentState = true, | ||
}: { | ||
members: ChannelMemberResponse<StreamChatGenerics>[]; | ||
/** | ||
* If set to `true` then `ChannelState.members` will be overriden with the newly | ||
* provided `members`, setting this property to `false` will merge current `ChannelState.members` | ||
* object with the newly provided `members` | ||
* (new members with the same `userId` will replace the old ones). | ||
*/ | ||
overrideCurrentState?: boolean; | ||
}) { | ||
const newMembersById = members.reduce<ChannelState<StreamChatGenerics>['members']>((membersById, member) => { | ||
if (member.user) { | ||
acc[member.user.id] = member; | ||
membersById[member.user.id] = member; | ||
} | ||
return acc; | ||
}, {} as ChannelState<StreamChatGenerics>['members']); | ||
return membersById; | ||
}, {}); | ||
if (overrideCurrentState) { | ||
this.state.members = newMembersById; | ||
} else if (!overrideCurrentState && members.length) { | ||
this.state.members = { | ||
...this.state.members, | ||
...newMembersById, | ||
}; | ||
} | ||
} | ||
@@ -1761,0 +1780,0 @@ |
@@ -81,3 +81,3 @@ import type { Channel } from './channel'; | ||
}); | ||
channel._hydrateMembers(threadData.channel.members ?? []); | ||
channel._hydrateMembers({ members: threadData.channel.members ?? [], overrideCurrentState: false }); | ||
@@ -84,0 +84,0 @@ // For when read object is undefined and due to that unreadMessageCount for |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
7387694
76907