From 78c79b148a4f3a0370b5f0419bc0f2cf46c780cb Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 20 Dec 2021 13:08:44 +0530 Subject: [PATCH] Refactor code --- src/matrix/room/timeline/entries/BaseEventEntry.js | 4 ++-- src/matrix/room/timeline/entries/reply.js | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/matrix/room/timeline/entries/BaseEventEntry.js b/src/matrix/room/timeline/entries/BaseEventEntry.js index b3ac3e9c..884bffa9 100644 --- a/src/matrix/room/timeline/entries/BaseEventEntry.js +++ b/src/matrix/room/timeline/entries/BaseEventEntry.js @@ -18,7 +18,7 @@ import {BaseEntry} from "./BaseEntry"; import {REDACTION_TYPE} from "../../common.js"; import {createAnnotation, ANNOTATION_RELATION_TYPE, getRelationFromContent} from "../relations.js"; import {PendingAnnotation} from "../PendingAnnotation.js"; -import {createReplyContent} from "./reply.js" +import {createReplyContent, THREADING_REL_TYPE} from "./reply.js" /** Deals mainly with local echo for relations and redactions, * so it is shared between PendingEventEntry and EventEntry */ @@ -36,7 +36,7 @@ export class BaseEventEntry extends BaseEntry { } get isThread() { - return this.relation?.["rel_type"] === "io.element.thread"; + return this.relation?.["rel_type"] === THREADING_REL_TYPE; } get isRedacting() { diff --git a/src/matrix/room/timeline/entries/reply.js b/src/matrix/room/timeline/entries/reply.js index bbb2d53d..2fbbd0d4 100644 --- a/src/matrix/room/timeline/entries/reply.js +++ b/src/matrix/room/timeline/entries/reply.js @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ +import {getRelatedEventId} from "../relations.js"; + +export const THREADING_REL_TYPE = "io.element.thread"; + function htmlEscape(string) { return string.replace(/&/g, "&").replace(//g, ">"); } @@ -81,8 +85,8 @@ function createThreadContent(entry, msgtype, body) { msgtype, body, "m.relates_to": { - "rel_type": "m.thread", - "event_id": entry.id + "rel_type": THREADING_REL_TYPE, + "event_id": getRelatedEventId(entry) } }; }