From 77561ced0749c0db7c243990a597a520518cdd26 Mon Sep 17 00:00:00 2001
From: Patrick Hettich
Date: Fri, 16 Feb 2024 11:47:26 +0100
Subject: [PATCH 1/3] fix: Use name of other participant on archived rooms
---
lib/src/room.dart | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/lib/src/room.dart b/lib/src/room.dart
index c4fffd7c..f1ec54c4 100644
--- a/lib/src/room.dart
+++ b/lib/src/room.dart
@@ -290,6 +290,19 @@ 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) {
final invitation = getState(EventTypes.RoomMember, client.userID!);
if (invitation != null &&
From 9b9e311010be541d43136eb76666b1a65780e75e Mon Sep 17 00:00:00 2001
From: Patrick Hettich
Date: Wed, 21 Feb 2024 08:16:10 +0100
Subject: [PATCH 2/3] 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) {
From 18ce3607c60581442ff854802d5481541caf675a Mon Sep 17 00:00:00 2001
From: Patrick Hettich
Date: Thu, 29 Feb 2024 11:57:32 +0100
Subject: [PATCH 3/3] fix: removed prev_sender for empty chats
---
lib/src/room.dart | 8 --------
1 file changed, 8 deletions(-)
diff --git a/lib/src/room.dart b/lib/src/room.dart
index 0f5997a9..2600e297 100644
--- a/lib/src/room.dart
+++ b/lib/src/room.dart
@@ -296,14 +296,6 @@ class Room {
unsafeGetUserFromMemoryOrFallback(directChatMatrixID)
.calcDisplayname(i18n: i18n));
}
- final invitation = getState(EventTypes.RoomMember, client.userID!);
- if (invitation != null &&
- invitation.unsigned?.tryGet('prev_sender') != null) {
- final name = unsafeGetUserFromMemoryOrFallback(
- invitation.unsigned!.tryGet('prev_sender')!)
- .calcDisplayname(i18n: i18n);
- return i18n.wasDirectChatDisplayName(name);
- }
}
return i18n.emptyChat;
}