You've already forked matrix-js-sdk
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:
@@ -40,6 +40,8 @@ export class Thread extends BaseModel<ThreadEvent> {
|
|||||||
*/
|
*/
|
||||||
public readonly timelineSet;
|
public readonly timelineSet;
|
||||||
|
|
||||||
|
private _currentUserParticipated = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
events: MatrixEvent[] = [],
|
events: MatrixEvent[] = [],
|
||||||
public readonly room: Room,
|
public readonly room: Room,
|
||||||
@@ -92,6 +94,10 @@ export class Thread extends BaseModel<ThreadEvent> {
|
|||||||
roomState,
|
roomState,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!this._currentUserParticipated && event.getSender() === this.client.getUserId()) {
|
||||||
|
this._currentUserParticipated = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.ready) {
|
if (this.ready) {
|
||||||
this.client.decryptEventIfNeeded(event, {});
|
this.client.decryptEventIfNeeded(event, {});
|
||||||
}
|
}
|
||||||
@@ -150,17 +156,6 @@ export class Thread extends BaseModel<ThreadEvent> {
|
|||||||
.length;
|
.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
|
* 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 {
|
public has(eventId: string): boolean {
|
||||||
return this.timelineSet.findEventById(eventId) instanceof MatrixEvent;
|
return this.timelineSet.findEventById(eventId) instanceof MatrixEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get hasCurrentUserParticipated(): boolean {
|
||||||
|
return this._currentUserParticipated;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user