1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-23 17:02:25 +03:00

Add reply events rendering hint

Adds an unstable hint for clients to know whether to render an event in the room timeline or in a thread

There are currently no MSC associated with that unstable "io.element.in_thread" property as I am only experimenting before settling on a specific approach
This commit is contained in:
Germain Souquet
2021-09-01 12:12:01 +01:00
parent 2783d162b7
commit fa44300abc
3 changed files with 23 additions and 2 deletions

View File

@@ -24,7 +24,12 @@ import { EventEmitter } from 'events';
import { logger } from '../logger';
import { VerificationRequest } from "../crypto/verification/request/VerificationRequest";
import { EventType, MsgType, RelationType } from "../@types/event";
import {
EventType,
MsgType,
RelationType,
UNSTABLE_ELEMENT_REPLY_IN_THREAD,
} from "../@types/event";
import { Crypto } from "../crypto";
import { deepSortedObjectEntries } from "../utils";
import { RoomMember } from "./room-member";
@@ -401,6 +406,17 @@ export class MatrixEvent extends EventEmitter {
return relations?.["m.in_reply_to"]?.["event_id"];
}
/**
* @experimental
* Determines whether a reply should be rendered in a thread
* or in the main room timeline
*/
public get replyInThread(): boolean {
const relations = this.getWireContent()["m.relates_to"];
return this.replyEventId
&& relations[UNSTABLE_ELEMENT_REPLY_IN_THREAD.name];
}
/**
* Get the previous event content JSON. This will only return something for
* state events which exist in the timeline.