diff --git a/src/modules/actions/api/chats.ts b/src/modules/actions/api/chats.ts index 170e58ea..392dd28a 100644 --- a/src/modules/actions/api/chats.ts +++ b/src/modules/actions/api/chats.ts @@ -953,12 +953,16 @@ addReducer('loadMoreMembers', (global) => { global = getGlobal(); global = addUsers(global, buildCollectionByKey(users, 'id')); + + const newMemberIds = new Set(members.map(m => m.userId)); + const preservedMembers = chat.fullInfo?.members?.filter((m) => !newMemberIds.has(m.userId)) || []; + global = updateChat(global, chat.id, { fullInfo: { ...chat.fullInfo, members: [ - ...((chat.fullInfo || {}).members || []), - ...(members || []), + ...preservedMembers, + ...members, ], }, });