Add thread serialisation helper

This commit is contained in:
Germain Souquet
2021-09-22 11:35:19 +01:00
parent b1d239b292
commit 5d4f347eaa
+12
View File
@@ -25,6 +25,11 @@ export enum ThreadEvent {
Update = "Thread.update"
}
interface ISerialisedThread {
id: string;
tails: string[];
}
/**
* @experimental
*/
@@ -199,6 +204,13 @@ export class Thread extends EventEmitter {
return this.timelineSet.findEventById(eventId) instanceof MatrixEvent;
}
public toJson(): ISerialisedThread {
return {
id: this.id,
tails: Array.from(this.tail),
};
}
public on(event: ThreadEvent, listener: (...args: any[]) => void): this {
super.on(event, listener);
return this;