Input field fixes

* Message with multiple mentions are not broken in IRC. Fix #267
* Editing a message won't remove mentions anymore


(cherry picked from commit bb3b3bc088)
This commit is contained in:
Carl Schwan
2021-02-22 19:09:56 +00:00
parent ffe9026830
commit 2f06d45589
8 changed files with 57 additions and 18 deletions

View File

@@ -47,6 +47,7 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
roles[ShowSectionRole] = "showSection";
roles[ReactionRole] = "reaction";
roles[IsEditedRole] = "isEdited";
roles[FormattedBodyRole] = "formattedBody";
return roles;
}
@@ -368,6 +369,16 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
return m_currentRoom->eventToString(evt, Qt::RichText);
}
if (role == FormattedBodyRole) {
if (auto e = eventCast<const RoomMessageEvent>(&evt)) {
if (e->hasTextContent() && e->mimeType().name() != "text/plain") {
return static_cast<const Quotient::EventContent::TextContent *>(e->content())->body;
}
}
return {};
}
if (role == MessageRole) {
return m_currentRoom->eventToString(evt);
}