summary refs log tree commit diff
path: root/src/timeline/TimelineModel.cpp
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2020-01-28 19:20:51 -0500
committerJoseph Donofry <joedonofry@gmail.com>2020-01-28 19:20:51 -0500
commitd6d4076d36bdc7171c7d422fb24f64f273ee5f83 (patch)
tree9ce36ae841adb047f736119badc08bf45b574b7e /src/timeline/TimelineModel.cpp
parentChange tooltip palette settings for QML (diff)
parentRemove stale deps folder (diff)
downloadnheko-d6d4076d36bdc7171c7d422fb24f64f273ee5f83.tar.xz
Merge branch '0.7.0-dev' of ssh://github.com/Nheko-Reborn/nheko into 0.7.0-dev
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r--src/timeline/TimelineModel.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp

index f66099a0..f34cb405 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -1,6 +1,7 @@ #include "TimelineModel.h" #include <algorithm> +#include <thread> #include <type_traits> #include <QFileDialog> @@ -280,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)));