summary refs log tree commit diff
path: root/src/timeline/TimelineModel.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-01-29 00:42:46 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-01-29 00:42:46 +0100
commit75c5c011891739d5223ca53193797dc47e0e2a0c (patch)
tree575511ace543a19f50c3fb4c4fda7e28718a7b95 /src/timeline/TimelineModel.cpp
parentMerge pull request #111 from Nheko-Reborn/better-build (diff)
parentAdd command for invite,kick,ban and unban (diff)
downloadnheko-75c5c011891739d5223ca53193797dc47e0e2a0c.tar.xz
Merge branch 'plain-text-messages' into 0.7.0-dev
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r--src/timeline/TimelineModel.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp

index fb8c0095..f34cb405 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -281,9 +281,26 @@ TimelineModel::data(const QString &id, int role) const case FormattedBody: { const static QRegularExpression replyFallback( "<mx-reply>.*</mx-reply>", QRegularExpression::DotMatchesEverythingOption); - return QVariant( - utils::replaceEmoji(utils::linkifyMessage(utils::escapeBlacklistedHtml( - formattedBodyWithFallback(event).remove(replyFallback))))); + + bool isReply = !in_reply_to_event(event).empty(); + + auto formattedBody_ = QString::fromStdString(formatted_body(event)); + if (formattedBody_.isEmpty()) { + auto body_ = QString::fromStdString(body(event)); + + if (isReply) { + while (body_.startsWith("> ")) + body_ = body_.right(body_.size() - body_.indexOf('\n') - 1); + if (body_.startsWith('\n')) + body_ = body_.right(body_.size() - 1); + } + formattedBody_ = body_.toHtmlEscaped().replace('\n', "<br>"); + } else { + if (isReply) + formattedBody_ = formattedBody_.remove(replyFallback); + } + return QVariant(utils::replaceEmoji( + utils::linkifyMessage(utils::escapeBlacklistedHtml(formattedBody_)))); } case Url: return QVariant(QString::fromStdString(url(event)));