Show old display name for name change events
BUG: 457664
This commit is contained in:
@@ -96,7 +96,7 @@ Control {
|
|||||||
Layout.preferredHeight: icon.height
|
Layout.preferredHeight: icon.height
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: `<style>a {text-decoration: none;}</style><a href="https://matrix.to/#/${author.id}" style="color: ${author.color}">${currentRoom.htmlSafeMemberName(author.id)}</a> ${aggregateDisplay}`
|
text: `<style>a {text-decoration: none;}</style><a href="https://matrix.to/#/${author.id}" style="color: ${author.color}">${model.authorDisplayName}</a> ${aggregateDisplay}`
|
||||||
onLinkActivated: userDetailDialog.createObject(ApplicationWindow.overlay, {room: currentRoom, user: author.object, displayName: author.displayName, avatarMediaId: author.avatarMediaId, avatarUrl: author.avatarUrl}).open()
|
onLinkActivated: userDetailDialog.createObject(ApplicationWindow.overlay, {room: currentRoom, user: author.object, displayName: author.displayName, avatarMediaId: author.avatarMediaId, avatarUrl: author.avatarUrl}).open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
|
|||||||
roles[MediaUrlRole] = "mediaUrl";
|
roles[MediaUrlRole] = "mediaUrl";
|
||||||
roles[VerifiedRole] = "verified";
|
roles[VerifiedRole] = "verified";
|
||||||
roles[DisplayNameForInitialsRole] = "displayNameForInitials";
|
roles[DisplayNameForInitialsRole] = "displayNameForInitials";
|
||||||
|
roles[AuthorDisplayNameRole] = "authorDisplayName";
|
||||||
return roles;
|
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()));
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,10 @@ public:
|
|||||||
EventResolvedTypeRole,
|
EventResolvedTypeRole,
|
||||||
AuthorIdRole,
|
AuthorIdRole,
|
||||||
VerifiedRole,
|
VerifiedRole,
|
||||||
|
|
||||||
// Sender's displayname, always without the matrix id
|
// Sender's displayname, always without the matrix id
|
||||||
DisplayNameForInitialsRole,
|
DisplayNameForInitialsRole,
|
||||||
|
// The displayname for the event's sender; for name change events, the old displayname
|
||||||
|
AuthorDisplayNameRole,
|
||||||
LastRole, // Keep this last
|
LastRole, // Keep this last
|
||||||
};
|
};
|
||||||
Q_ENUM(EventRoles)
|
Q_ENUM(EventRoles)
|
||||||
|
|||||||
Reference in New Issue
Block a user