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

Merge pull request #1876 from matrix-org/gsouquet/replies-fix-18717

Add reply events rendering hint
This commit is contained in:
Germain
2021-09-02 08:37:11 +01:00
committed by GitHub
3 changed files with 23 additions and 2 deletions

View File

@@ -168,6 +168,11 @@ export const UNSTABLE_ELEMENT_FUNCTIONAL_USERS = new UnstableValue(
"io.element.functional_members",
"io.element.functional_members");
export const UNSTABLE_ELEMENT_REPLY_IN_THREAD = new UnstableValue(
"m.in_thread",
"io.element.in_thread",
);
export interface IEncryptedFile {
url: string;
mimetype?: string;

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.

View File

@@ -315,7 +315,7 @@ export class SyncApi {
public partitionThreadedEvents(events: MatrixEvent[]): [MatrixEvent[], MatrixEvent[]] {
if (this.opts.experimentalThreadSupport) {
return events.reduce((memo, event: MatrixEvent) => {
memo[event.replyEventId ? 1 : 0].push(event);
memo[event.replyInThread ? 1 : 0].push(event);
return memo;
}, [[], []]);
} else {