You've already forked matrix-js-sdk
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:
@@ -168,6 +168,11 @@ export const UNSTABLE_ELEMENT_FUNCTIONAL_USERS = new UnstableValue(
|
|||||||
"io.element.functional_members",
|
"io.element.functional_members",
|
||||||
"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 {
|
export interface IEncryptedFile {
|
||||||
url: string;
|
url: string;
|
||||||
mimetype?: string;
|
mimetype?: string;
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ import { EventEmitter } from 'events';
|
|||||||
|
|
||||||
import { logger } from '../logger';
|
import { logger } from '../logger';
|
||||||
import { VerificationRequest } from "../crypto/verification/request/VerificationRequest";
|
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 { Crypto } from "../crypto";
|
||||||
import { deepSortedObjectEntries } from "../utils";
|
import { deepSortedObjectEntries } from "../utils";
|
||||||
import { RoomMember } from "./room-member";
|
import { RoomMember } from "./room-member";
|
||||||
@@ -401,6 +406,17 @@ export class MatrixEvent extends EventEmitter {
|
|||||||
return relations?.["m.in_reply_to"]?.["event_id"];
|
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
|
* Get the previous event content JSON. This will only return something for
|
||||||
* state events which exist in the timeline.
|
* state events which exist in the timeline.
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ export class SyncApi {
|
|||||||
public partitionThreadedEvents(events: MatrixEvent[]): [MatrixEvent[], MatrixEvent[]] {
|
public partitionThreadedEvents(events: MatrixEvent[]): [MatrixEvent[], MatrixEvent[]] {
|
||||||
if (this.opts.experimentalThreadSupport) {
|
if (this.opts.experimentalThreadSupport) {
|
||||||
return events.reduce((memo, event: MatrixEvent) => {
|
return events.reduce((memo, event: MatrixEvent) => {
|
||||||
memo[event.replyEventId ? 1 : 0].push(event);
|
memo[event.replyInThread ? 1 : 0].push(event);
|
||||||
return memo;
|
return memo;
|
||||||
}, [[], []]);
|
}, [[], []]);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user