diff --git a/src/messageeventmodel.cpp b/src/messageeventmodel.cpp index 00e7dbf6f..e2c8db638 100644 --- a/src/messageeventmodel.cpp +++ b/src/messageeventmodel.cpp @@ -842,7 +842,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const } if (role == AuthorDisplayNameRole) { - if (!evt.unsignedJson()["prev_content"]["displayname"].isNull()) { + if (is(evt) && !evt.unsignedJson()["prev_content"]["displayname"].isNull() && evt.stateKey() == evt.senderId()) { auto previousDisplayName = evt.unsignedJson()["prev_content"]["displayname"].toString().toHtmlEscaped(); if (previousDisplayName.isEmpty()) { previousDisplayName = evt.senderId(); @@ -850,7 +850,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const return previousDisplayName; } else { auto author = static_cast(isPending ? m_currentRoom->localUser() : m_currentRoom->user(evt.senderId())); - m_currentRoom->htmlSafeMemberName(author->id()); + return m_currentRoom->htmlSafeMemberName(author->id()); } }