Show old display name for name change events

BUG: 457664
This commit is contained in:
Tobias Fella
2022-10-23 15:55:39 +02:00
parent bbf76e1e64
commit a9c80b90f6
3 changed files with 17 additions and 2 deletions

View File

@@ -60,6 +60,7 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
roles[MediaUrlRole] = "mediaUrl";
roles[VerifiedRole] = "verified";
roles[DisplayNameForInitialsRole] = "displayNameForInitials";
roles[AuthorDisplayNameRole] = "authorDisplayName";
return roles;
}
@@ -840,6 +841,19 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
return user->displayname(m_currentRoom).remove(QStringLiteral(" (%1)").arg(user->id()));
}
if (role == AuthorDisplayNameRole) {
if (!evt.unsignedJson()["prev_content"]["displayname"].isNull()) {
auto previousDisplayName = evt.unsignedJson()["prev_content"]["displayname"].toString().toHtmlEscaped();
if (previousDisplayName.isEmpty()) {
previousDisplayName = evt.senderId();
}
return previousDisplayName;
} else {
auto author = static_cast<NeoChatUser *>(isPending ? m_currentRoom->localUser() : m_currentRoom->user(evt.senderId()));
m_currentRoom->htmlSafeMemberName(author->id());
}
}
return {};
}