Skip to content

Commit

Permalink
Merge branch 'master' into fix/search-thread-participants
Browse files Browse the repository at this point in the history
  • Loading branch information
kanat authored Dec 11, 2024
2 parents 7102756 + af63684 commit bbe618c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [8.46.1](https://github.com/GetStream/stream-chat-js/compare/v8.46.0...v8.46.1) (2024-12-11)


### Bug Fixes

* update membership object on member events ([#1409](https://github.com/GetStream/stream-chat-js/issues/1409)) ([5d1e4c4](https://github.com/GetStream/stream-chat-js/commit/5d1e4c4ffaf68bb372cefb6fde769858498a143e))

## [8.46.0](https://github.com/GetStream/stream-chat-js/compare/v8.45.3...v8.46.0) (2024-12-03)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stream-chat",
"version": "8.46.0",
"version": "8.46.1",
"description": "JS SDK for the Stream Chat API",
"author": "GetStream",
"homepage": "https://getstream.io/chat/",
Expand Down
19 changes: 16 additions & 3 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1555,12 +1555,20 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
break;
case 'member.added':
case 'member.updated':
if (event.member?.user_id) {
if (event.member?.user) {
channelState.members = {
...channelState.members,
[event.member.user_id]: event.member,
[event.member.user.id]: event.member,
};
}

if (
typeof channelState.membership.user?.id === 'string' &&
typeof event.member?.user?.id === 'string' &&
event.member.user.id === channelState.membership.user.id
) {
channelState.membership = event.member;
}
break;
case 'member.removed':
if (event.user?.id) {
Expand All @@ -1571,6 +1579,8 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
delete newMembers[event.user.id];

channelState.members = newMembers;

// TODO?: unset membership
}
break;
case 'notification.mark_unread': {
Expand Down Expand Up @@ -1712,7 +1722,10 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
}
}

this.state.membership = state.membership || {};
this.state.membership = {
...this.state.membership,
...state.membership,
};

const messages = state.messages || [];
if (!this.state.messages) {
Expand Down

0 comments on commit bbe618c

Please sign in to comment.