fix: updated membership-leave for archived direct chats

This commit is contained in:
Patrick Hettich 2024-02-21 08:16:10 +01:00
parent 77561ced07
commit 9b9e311010
No known key found for this signature in database
GPG Key ID: 79CFBB24199A38F3
1 changed files with 5 additions and 13 deletions

View File

@ -290,20 +290,12 @@ class Room {
.calcDisplayname(i18n: i18n); .calcDisplayname(i18n: i18n);
if (sender != null) return sender; if (sender != null) return sender;
} }
if (isArchived) {
// In case of a direct chat, we need to get the room-members via the RoomMember event-type
// then we have to make sure to get the other room-member that is not us, to add them to the display name.
final roomMemberEvents = states.entries
.firstWhereOrNull((element) => element.key == EventTypes.RoomMember);
final otherRoomMember = roomMemberEvents?.value.entries
.firstWhereOrNull((entry) => entry.value.senderId != client.userID);
if (otherRoomMember?.value.prevContent?.tryGet('displayname') != null) {
return i18n.wasDirectChatDisplayName(
otherRoomMember!.value.prevContent!.tryGet('displayname')!);
}
}
if (membership == Membership.leave) { if (membership == Membership.leave) {
if (directChatMatrixID != null) {
return i18n.wasDirectChatDisplayName(
unsafeGetUserFromMemoryOrFallback(directChatMatrixID)
.calcDisplayname(i18n: i18n));
}
final invitation = getState(EventTypes.RoomMember, client.userID!); final invitation = getState(EventTypes.RoomMember, client.userID!);
if (invitation != null && if (invitation != null &&
invitation.unsigned?.tryGet<String>('prev_sender') != null) { invitation.unsigned?.tryGet<String>('prev_sender') != null) {