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

Make threads reply chain filter out local event ID (#2129)

This commit is contained in:
Germain
2022-01-25 10:51:12 +00:00
committed by GitHub
parent a34426a7f6
commit 8434f29c54

View File

@@ -138,10 +138,13 @@ export class Thread extends TypedEventEmitter<ThreadEvent> {
/**
* Return last reply to the thread
*/
public get lastReply(): MatrixEvent {
const threadReplies = this.events
.filter(event => event.isThreadRelation);
return threadReplies[threadReplies.length - 1];
public lastReply(matches: (ev: MatrixEvent) => boolean = () => true): MatrixEvent {
for (let i = this.events.length - 1; i >= 0; i--) {
const event = this.events[i];
if (event.isThreadRelation && matches(event)) {
return event;
}
}
}
/**