1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-04 05:02:41 +03:00

Add a flag to track user participation in a thread (#2030)

This commit is contained in:
Germain
2021-11-23 08:20:27 +00:00
committed by GitHub
parent 04fad564f7
commit 67b8da719f

View File

@@ -40,6 +40,8 @@ export class Thread extends BaseModel<ThreadEvent> {
*/
public readonly timelineSet;
private _currentUserParticipated = false;
constructor(
events: MatrixEvent[] = [],
public readonly room: Room,
@@ -92,6 +94,10 @@ export class Thread extends BaseModel<ThreadEvent> {
roomState,
);
if (!this._currentUserParticipated && event.getSender() === this.client.getUserId()) {
this._currentUserParticipated = true;
}
if (this.ready) {
this.client.decryptEventIfNeeded(event, {});
}
@@ -150,17 +156,6 @@ export class Thread extends BaseModel<ThreadEvent> {
.length;
}
/**
* A set of mxid participating to the thread
*/
public get participants(): Set<string> {
const participants = new Set<string>();
this.events.forEach(event => {
participants.add(event.getSender());
});
return participants;
}
/**
* A getter for the last event added to the thread
*/
@@ -183,4 +178,8 @@ export class Thread extends BaseModel<ThreadEvent> {
public has(eventId: string): boolean {
return this.timelineSet.findEventById(eventId) instanceof MatrixEvent;
}
public get hasCurrentUserParticipated(): boolean {
return this._currentUserParticipated;
}
}