fix: Use name of other participant on archived rooms

This commit is contained in:
Patrick Hettich 2024-02-16 11:47:26 +01:00
parent 5220f2d127
commit 77561ced07
No known key found for this signature in database
GPG Key ID: 79CFBB24199A38F3
1 changed files with 13 additions and 0 deletions

View File

@ -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 &&