From 9eeeea47d9dd9f7e2b4f5d80adab6dce951801b6 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 14 Dec 2021 17:55:04 +0530 Subject: [PATCH] Treat replies to thread as threaded message --- src/matrix/room/timeline/entries/BaseEventEntry.js | 6 +++++- src/matrix/room/timeline/entries/reply.js | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/matrix/room/timeline/entries/BaseEventEntry.js b/src/matrix/room/timeline/entries/BaseEventEntry.js index ec20f48a..b3ac3e9c 100644 --- a/src/matrix/room/timeline/entries/BaseEventEntry.js +++ b/src/matrix/room/timeline/entries/BaseEventEntry.js @@ -32,7 +32,11 @@ export class BaseEventEntry extends BaseEntry { } get isReply() { - return !!this.relation?.["m.in_reply_to"]; + return !!(this.relation?.["m.in_reply_to"] || this.isThread); + } + + get isThread() { + return this.relation?.["rel_type"] === "io.element.thread"; } get isRedacting() { diff --git a/src/matrix/room/timeline/entries/reply.js b/src/matrix/room/timeline/entries/reply.js index 2e180c11..bbb2d53d 100644 --- a/src/matrix/room/timeline/entries/reply.js +++ b/src/matrix/room/timeline/entries/reply.js @@ -51,6 +51,9 @@ function _createReplyContent(targetId, msgtype, body, formattedBody) { } export function createReplyContent(entry, msgtype, body) { + if (entry.isThread) { + return createThreadContent(entry, msgtype, body); + } // TODO check for absense of sender / body / msgtype / etc? const nonTextual = fallbackForNonTextualMessage(entry.content.msgtype); const prefix = fallbackPrefix(entry.content.msgtype); @@ -72,3 +75,14 @@ export function createReplyContent(entry, msgtype, body) { const newFormattedBody = formattedFallback + htmlEscape(body); return _createReplyContent(entry.id, msgtype, newBody, newFormattedBody); } + +function createThreadContent(entry, msgtype, body) { + return { + msgtype, + body, + "m.relates_to": { + "rel_type": "m.thread", + "event_id": entry.id + } + }; +}