From 39576fea96c6cac275addc1602f1cc5af464f745 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 20 Feb 2021 13:05:21 -0500 Subject: [PATCH] Create function for processing whether a message is a reply --- src/Utils.cpp | 7 +++++++ src/Utils.h | 3 +++ src/timeline/TimelineModel.cpp | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Utils.cpp b/src/Utils.cpp index 5c03c52f..40c16fd3 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -24,6 +24,7 @@ #include "Cache.h" #include "Config.h" +#include "EventAccessors.h" #include "MatrixClient.h" #include "UserSettingsPage.h" @@ -696,3 +697,9 @@ utils::readImage(const QByteArray *data) reader.setAutoTransform(true); return reader.read(); } + +bool +utils::isReply(const mtx::events::collections::TimelineEvents &e) +{ + return mtx::accessors::relations(e).reply_to().has_value(); +} diff --git a/src/Utils.h b/src/Utils.h index 373bed01..1dc5ffd6 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -310,4 +310,7 @@ restoreCombobox(QComboBox *combo, const QString &value); //! Read image respecting exif orientation QImage readImage(const QByteArray *data); + +bool +isReply(const mtx::events::collections::TimelineEvents &e); } diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 004cf26a..cfca626a 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -369,7 +369,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r auto ascent = QFontMetrics(UserSettings::instance()->font()).ascent(); - bool isReply = relations(event).reply_to().has_value(); + bool isReply = utils::isReply(event); auto formattedBody_ = QString::fromStdString(formatted_body(event)); if (formattedBody_.isEmpty()) {