Fix reply rendering without markdown in riot
This commit is contained in:
parent
e2f547149a
commit
9c368fa7f4
@ -281,9 +281,26 @@ TimelineModel::data(const QString &id, int role) const
|
|||||||
case FormattedBody: {
|
case FormattedBody: {
|
||||||
const static QRegularExpression replyFallback(
|
const static QRegularExpression replyFallback(
|
||||||
"<mx-reply>.*</mx-reply>", QRegularExpression::DotMatchesEverythingOption);
|
"<mx-reply>.*</mx-reply>", QRegularExpression::DotMatchesEverythingOption);
|
||||||
return QVariant(
|
|
||||||
utils::replaceEmoji(utils::linkifyMessage(utils::escapeBlacklistedHtml(
|
bool isReply = !in_reply_to_event(event).empty();
|
||||||
formattedBodyWithFallback(event).remove(replyFallback)))));
|
|
||||||
|
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:
|
case Url:
|
||||||
return QVariant(QString::fromStdString(url(event)));
|
return QVariant(QString::fromStdString(url(event)));
|
||||||
|
@ -186,8 +186,11 @@ TimelineViewManager::queueTextMessage(const QString &msg, const std::optional<Re
|
|||||||
{
|
{
|
||||||
mtx::events::msg::Text text = {};
|
mtx::events::msg::Text text = {};
|
||||||
text.body = msg.trimmed().toStdString();
|
text.body = msg.trimmed().toStdString();
|
||||||
text.format = "org.matrix.custom.html";
|
|
||||||
text.formatted_body = utils::markdownToHtml(msg).toStdString();
|
if (settings->isMarkdownEnabled()) {
|
||||||
|
text.format = "org.matrix.custom.html";
|
||||||
|
text.formatted_body = utils::markdownToHtml(msg).toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
if (related) {
|
if (related) {
|
||||||
QString body;
|
QString body;
|
||||||
@ -202,14 +205,18 @@ TimelineViewManager::queueTextMessage(const QString &msg, const std::optional<Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
text.body = QString("%1\n%2").arg(body).arg(msg).toStdString();
|
text.body = QString("%1\n%2").arg(body).arg(msg).toStdString();
|
||||||
text.formatted_body =
|
|
||||||
utils::getFormattedQuoteBody(*related, utils::markdownToHtml(msg)).toStdString();
|
|
||||||
text.relates_to.in_reply_to.event_id = related->related_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!settings->isMarkdownEnabled()) {
|
// NOTE(Nico): rich replies always need a formatted_body!
|
||||||
text.format = "";
|
text.format = "org.matrix.custom.html";
|
||||||
text.formatted_body = "";
|
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_)
|
if (timeline_)
|
||||||
|
Loading…
Reference in New Issue
Block a user