Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Alexey Rusakov <[email protected]>
  • Loading branch information
rpallai and KitsuneRal authored Apr 17, 2023
1 parent 683a974 commit 3d11ddc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/chatroomwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ bool ChatRoomWidget::setReferringMode(const int newMode, const QString& eventId,
const char* icon_name)
{
Q_ASSERT( newMode == Replying || newMode == Editing );
// Actually, we could let the user to refer to pending events too but in
// Actually, we could let the user refer to pending events too but in
// this case we would need a universal pointer instead of event id. Now the
// user cannot start to edit a pending message which might be annoying if
// transactions are acknowledged slowly.
Expand Down
14 changes: 7 additions & 7 deletions client/models/messageeventmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const
evt, [](const RoomCreateEvent& e) { return e.predecessor().roomId; },
[](const RoomTombstoneEvent& e) { return e.successorRoomId(); });

if (role == NudeRichBodyRole)
if (role == BareRichBodyRole)
{
auto e = eventCast<const Quotient::RoomMessageEvent>(&evt);
if (!e || !e->hasTextContent())
Expand All @@ -934,21 +934,21 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const
QRegularExpression::DotMatchesEverythingOption
};
static const QRegularExpression quoteLines("> .*(?:\n|$)");
QString nudeBody;
QString bareBody;
if (e->mimeType().name() != "text/plain") {
// Naïvely assume that it's HTML
auto htmlBody =
static_cast<const MessageEventContent::TextContent*>(e->content())->body;
auto [cleanHtml, errorPos, errorString] =
HtmlFilter::fromMatrixHtml(htmlBody.remove(quoteBlock), m_currentRoom);
if (errorPos == -1) {
nudeBody = cleanHtml;
bareBody = cleanHtml;
}
}
if (nudeBody.isEmpty()) {
nudeBody = m_currentRoom->prettyPrint(e->plainBody().remove(quoteLines));
if (bareBody.isEmpty()) {
bareBody = m_currentRoom->prettyPrint(e->plainBody().remove(quoteLines));
}
return nudeBody;
return bareBody;
}

if (role == QuotationRole)
Expand All @@ -974,7 +974,7 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const
{
if (isPending)
return QString(); // Cannot construct event link with unknown eventId
QString quotation = data(idx, NudeRichBodyRole).toString();
QString quotation = data(idx, BareRichBodyRole).toString();
if (quotation.isEmpty())
return QString();
const auto authorUser = m_currentRoom->user(evt.senderId());
Expand Down
2 changes: 1 addition & 1 deletion client/models/messageeventmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MessageEventModel: public QAbstractListModel
RefRole,
ReactionsRole,
EventResolvedTypeRole,
NudeRichBodyRole,
BareRichBodyRole,
QuotationRole,
HtmlQuotationRole,
};
Expand Down

0 comments on commit 3d11ddc

Please sign in to comment.