Fix broken direct room member for rooms with old users that left (#3324)

This patch fixes getDirectRoomMember not respecting direct rooms
with more than two members total but only two active. This commonly
occurs when users migrate to a new account by adding a new account
to rooms and leaving with the old one.

Other parts of the codebase (such as the people room list filter)
already respect the active member count of a room instead of the
total (historic) number of unique members.

This fixes the room details screen not showing up correctly, for
example missing the avatar cluster.

Signed-off-by: networkException <git@nwex.de>
This commit is contained in:
networkException
2024-08-22 14:47:13 +02:00
committed by GitHub
parent 9e2aac8e44
commit 12648c42de

View File

@@ -58,6 +58,7 @@ fun MatrixRoom.getDirectRoomMember(roomMembersState: MatrixRoomMembersState): St
return remember(roomMembersState) {
derivedStateOf {
roomMembers
?.filter { it.membership.isActive() }
?.takeIf { it.size == 2 && isDirect && isEncrypted }
?.find { it.userId != sessionId }
}