From f755550418cac8c088a4d05c5be161c447c964c3 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 25 Jan 2020 01:06:01 +0100 Subject: Add missing thread include --- src/timeline/TimelineModel.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/timeline/TimelineModel.cpp') diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index f66099a0..fb8c0095 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -1,6 +1,7 @@ #include "TimelineModel.h" #include +#include #include #include -- cgit 1.5.1 From 9c368fa7f448715c2ce04c61097e0cb18091774b Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 27 Jan 2020 17:05:40 +0100 Subject: Fix reply rendering without markdown in riot --- src/timeline/TimelineModel.cpp | 23 ++++++++++++++++++++--- src/timeline/TimelineViewManager.cpp | 25 ++++++++++++++++--------- 2 files changed, 36 insertions(+), 12 deletions(-) (limited to 'src/timeline/TimelineModel.cpp') diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index fb8c0095..03b7d6a7 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( ".*", 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(); + } else { + if (isReply) + formattedBody_ = formattedBody_.remove(replyFallback); + } + return QVariant(utils::replaceEmoji( + utils::linkifyMessage(utils::escapeBlacklistedHtml(formattedBody_)))); } case Url: return QVariant(QString::fromStdString(url(event))); diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 578d075f..9008d9d2 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -186,8 +186,11 @@ TimelineViewManager::queueTextMessage(const QString &msg, const std::optionalisMarkdownEnabled()) { + text.format = "org.matrix.custom.html"; + text.formatted_body = utils::markdownToHtml(msg).toStdString(); + } if (related) { QString body; @@ -202,14 +205,18 @@ TimelineViewManager::queueTextMessage(const QString &msg, const std::optionalrelated_event; - } - if (!settings->isMarkdownEnabled()) { - text.format = ""; - text.formatted_body = ""; + // NOTE(Nico): rich replies always need a formatted_body! + text.format = "org.matrix.custom.html"; + if (settings->isMarkdownEnabled()) + text.formatted_body = + utils::getFormattedQuoteBody(*related, utils::markdownToHtml(msg)) + .toStdString(); + else + text.formatted_body = + utils::getFormattedQuoteBody(*related, msg.toHtmlEscaped()).toStdString(); + + text.relates_to.in_reply_to.event_id = related->related_event; } if (timeline_) -- cgit 1.5.1 From 760d4ddef9b5af92272a4422f8bc5ed4b3f005ed Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 27 Jan 2020 18:36:34 +0100 Subject: Fix newlines in plain text messages again --- src/timeline/TimelineModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/timeline/TimelineModel.cpp') diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 03b7d6a7..f34cb405 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -294,7 +294,7 @@ TimelineModel::data(const QString &id, int role) const if (body_.startsWith('\n')) body_ = body_.right(body_.size() - 1); } - formattedBody_ = body_.toHtmlEscaped(); + formattedBody_ = body_.toHtmlEscaped().replace('\n', "
"); } else { if (isReply) formattedBody_ = formattedBody_.remove(replyFallback); -- cgit 1.5.1