diff --git a/src/timeline/TimelineItem.cpp b/src/timeline/TimelineItem.cpp
index dd09ec78..bf5b1b53 100644
--- a/src/timeline/TimelineItem.cpp
+++ b/src/timeline/TimelineItem.cpp
@@ -874,8 +874,12 @@ TimelineItem::replyAction()
if (!body_)
return;
- emit ChatPage::instance()->messageReply(
- Cache::displayName(room_id_, descriptionMsg_.userid), body_->toPlainText(), eventId());
+ RelatedInfo related;
+ related.quoted_body = body_->toPlainText();
+ related.quoted_user = descriptionMsg_.userid;
+ related.related_event = eventId().toStdString();
+
+ emit ChatPage::instance()->messageReply(related);
}
void
diff --git a/src/timeline/TimelineView.cpp b/src/timeline/TimelineView.cpp
index 6d947c15..fc89fd38 100644
--- a/src/timeline/TimelineView.cpp
+++ b/src/timeline/TimelineView.cpp
@@ -692,7 +692,7 @@ TimelineView::updatePendingMessage(const std::string &txn_id, const QString &eve
void
TimelineView::addUserMessage(mtx::events::MessageType ty,
const QString &body,
- const QString &related_event)
+ const RelatedInfo &related = RelatedInfo())
{
auto with_sender = (lastSender_ != local_user_) || isDateDifference(lastMsgTimestamp_);
@@ -700,13 +700,11 @@ TimelineView::addUserMessage(mtx::events::MessageType ty,
new TimelineItem(ty, local_user_, body, with_sender, room_id_, scroll_widget_);
PendingMessage message;
- message.ty = ty;
- message.txn_id = http::client()->generate_txn_id();
- message.body = body;
- message.widget = view_item;
- if (!related_event.isEmpty()) {
- message.related_event = related_event.toStdString();
- }
+ message.ty = ty;
+ message.txn_id = http::client()->generate_txn_id();
+ message.body = body;
+ message.widget = view_item;
+ message.related = related;
try {
message.is_encrypted = cache::client()->isRoomEncrypted(room_id_.toStdString());
@@ -730,7 +728,7 @@ TimelineView::addUserMessage(mtx::events::MessageType ty,
void
TimelineView::addUserMessage(mtx::events::MessageType ty, const QString &body)
{
- addUserMessage(ty, body, "");
+ addUserMessage(ty, body, RelatedInfo());
}
void
@@ -1273,13 +1271,20 @@ toRoomMessage<mtx::events::msg::Text>(const PendingMessage &m)
auto html = utils::markdownToHtml(m.body);
mtx::events::msg::Text text;
+
text.body = m.body.trimmed().toStdString();
- if (html != m.body.trimmed().toHtmlEscaped())
- text.formatted_body = html.toStdString();
+ if (html != m.body.trimmed().toHtmlEscaped()) {
+ if (!m.related.quoted_body.isEmpty()) {
+ text.formatted_body =
+ utils::getFormattedQuoteBody(m.related, html).toStdString();
+ } else {
+ text.formatted_body = html.toStdString();
+ }
+ }
- if (!m.related_event.empty()) {
- text.relates_to.in_reply_to.event_id = m.related_event;
+ if (!m.related.related_event.empty()) {
+ text.relates_to.in_reply_to.event_id = m.related.related_event;
}
return text;
diff --git a/src/timeline/TimelineView.h b/src/timeline/TimelineView.h
index db6087eb..35796efd 100644
--- a/src/timeline/TimelineView.h
+++ b/src/timeline/TimelineView.h
@@ -30,6 +30,7 @@
#include <mtx/events.hpp>
#include <mtx/responses/messages.hpp>
+#include "../Utils.h"
#include "MatrixClient.h"
#include "timeline/TimelineItem.h"
@@ -63,7 +64,7 @@ struct PendingMessage
{
mtx::events::MessageType ty;
std::string txn_id;
- std::string related_event;
+ RelatedInfo related;
QString body;
QString filename;
QString mime;
@@ -123,7 +124,7 @@ public:
void addEvents(const mtx::responses::Timeline &timeline);
void addUserMessage(mtx::events::MessageType ty,
const QString &body,
- const QString &related_event);
+ const RelatedInfo &related);
void addUserMessage(mtx::events::MessageType ty, const QString &msg);
template<class Widget, mtx::events::MessageType MsgType>
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index 1ce3794f..86505481 100644
--- a/src/timeline/TimelineViewManager.cpp
+++ b/src/timeline/TimelineViewManager.cpp
@@ -23,6 +23,7 @@
#include "Cache.h"
#include "Logging.h"
+#include "Utils.h"
#include "timeline/TimelineView.h"
#include "timeline/TimelineViewManager.h"
#include "timeline/widgets/AudioItem.h"
@@ -79,7 +80,7 @@ TimelineViewManager::queueEmoteMessage(const QString &msg)
}
void
-TimelineViewManager::queueReplyMessage(const QString &reply, const QString &related_event)
+TimelineViewManager::queueReplyMessage(const QString &reply, const RelatedInfo &related)
{
if (active_room_.isEmpty())
return;
@@ -87,7 +88,7 @@ TimelineViewManager::queueReplyMessage(const QString &reply, const QString &rela
auto room_id = active_room_;
auto view = views_[room_id];
- view->addUserMessage(mtx::events::MessageType::Text, reply, related_event);
+ view->addUserMessage(mtx::events::MessageType::Text, reply, related);
}
void
diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index 0ac6d67e..b52136d9 100644
--- a/src/timeline/TimelineViewManager.h
+++ b/src/timeline/TimelineViewManager.h
@@ -22,6 +22,8 @@
#include <mtx.hpp>
+#include "Utils.h"
+
class QFile;
class RoomInfoListItem;
@@ -63,7 +65,7 @@ public slots:
void setHistoryView(const QString &room_id);
void queueTextMessage(const QString &msg);
- void queueReplyMessage(const QString &reply, const QString &related_event);
+ void queueReplyMessage(const QString &reply, const RelatedInfo &related);
void queueEmoteMessage(const QString &msg);
void queueImageMessage(const QString &roomid,
const QString &filename,
|