Skip to content

Commit

Permalink
Update user reference in channel read data
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Nov 2, 2023
1 parent 89485ab commit 55c3ddc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1094,22 +1094,24 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
};

/**
* Updates the members and watchers of the currently active channels that contain this user
* Updates the members, watchers and read references of the currently active channels that contain this user
*
* @param {UserResponse<StreamChatGenerics>} user
*/
_updateMemberWatcherReferences = (user: UserResponse<StreamChatGenerics>) => {
const refMap = this.state.userChannelReferences[user.id] || {};
for (const channelID in refMap) {
const channel = this.activeChannels[channelID];
/** search the members and watchers and update as needed... */
if (channel?.state) {
if (channel.state.members[user.id]) {
channel.state.members[user.id].user = user;
}
if (channel.state.watchers[user.id]) {
channel.state.watchers[user.id] = user;
}
if (channel.state.read[user.id]) {
channel.state.read[user.id].user = user;
}
}
}
};
Expand Down

0 comments on commit 55c3ddc

Please sign in to comment.