From 9b9e311010be541d43136eb76666b1a65780e75e Mon Sep 17 00:00:00 2001
From: Patrick Hettich
Date: Wed, 21 Feb 2024 08:16:10 +0100
Subject: [PATCH] fix: updated membership-leave for archived direct chats
---
lib/src/room.dart | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/lib/src/room.dart b/lib/src/room.dart
index f1ec54c4..0f5997a9 100644
--- a/lib/src/room.dart
+++ b/lib/src/room.dart
@@ -290,20 +290,12 @@ class Room {
.calcDisplayname(i18n: i18n);
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 (directChatMatrixID != null) {
+ return i18n.wasDirectChatDisplayName(
+ unsafeGetUserFromMemoryOrFallback(directChatMatrixID)
+ .calcDisplayname(i18n: i18n));
+ }
final invitation = getState(EventTypes.RoomMember, client.userID!);
if (invitation != null &&
invitation.unsigned?.tryGet('prev_sender') != null) {