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

Merge remote-tracking branch 'upstream/develop' into fix/call-notifs

This commit is contained in:
Šimon Brandner
2021-09-02 16:32:26 +02:00
14 changed files with 575 additions and 169 deletions

View File

@@ -28,7 +28,9 @@ import { EventType, MsgType, RelationType } from "../@types/event";
import { Crypto } from "../crypto";
import { deepSortedObjectEntries } from "../utils";
import { RoomMember } from "./room-member";
import { Thread } from "./thread";
import { IActionsObject } from '../pushprocessor';
import { ReEmitter } from '../ReEmitter';
/**
* Enum for event statuses.
@@ -192,6 +194,12 @@ export class MatrixEvent extends EventEmitter {
*/
private txnId: string = null;
/**
* @experimental
* A reference to the thread this event belongs to
*/
private thread: Thread = null;
/* Set an approximate timestamp for the event relative the local clock.
* This will inherently be approximate because it doesn't take into account
* the time between the server putting the 'age' field on the event as it sent
@@ -213,6 +221,8 @@ export class MatrixEvent extends EventEmitter {
*/
public verificationRequest = null;
private readonly reEmitter: ReEmitter;
/**
* Construct a Matrix Event object
* @constructor
@@ -262,6 +272,7 @@ export class MatrixEvent extends EventEmitter {
this.txnId = event.txn_id || null;
this.localTimestamp = Date.now() - this.getAge();
this.reEmitter = new ReEmitter(this);
}
/**
@@ -382,6 +393,15 @@ export class MatrixEvent extends EventEmitter {
return this.event.content || {};
}
/**
* @experimental
* Get the event ID of the replied event
*/
public get replyEventId(): string {
const relations = this.getWireContent()["m.relates_to"];
return relations?.["m.in_reply_to"]?.["event_id"];
}
/**
* Get the previous event content JSON. This will only return something for
* state events which exist in the timeline.
@@ -1285,6 +1305,21 @@ export class MatrixEvent extends EventEmitter {
public getTxnId(): string | undefined {
return this.txnId;
}
/**
* @experimental
*/
public setThread(thread: Thread): void {
this.thread = thread;
this.reEmitter.reEmit(thread, ["Thread.ready", "Thread.update"]);
}
/**
* @experimental
*/
public getThread(): Thread {
return this.thread;
}
}
/* REDACT_KEEP_KEYS gives the keys we keep when an event is redacted