Skip to content

Commit 8434f29

Browse files
author
Germain
authored
Make threads reply chain filter out local event ID (#2129)
1 parent a34426a commit 8434f29

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/models/thread.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@ export class Thread extends TypedEventEmitter<ThreadEvent> {
138138
/**
139139
* Return last reply to the thread
140140
*/
141-
public get lastReply(): MatrixEvent {
142-
const threadReplies = this.events
143-
.filter(event => event.isThreadRelation);
144-
return threadReplies[threadReplies.length - 1];
141+
public lastReply(matches: (ev: MatrixEvent) => boolean = () => true): MatrixEvent {
142+
for (let i = this.events.length - 1; i >= 0; i--) {
143+
const event = this.events[i];
144+
if (event.isThreadRelation && matches(event)) {
145+
return event;
146+
}
147+
}
145148
}
146149

147150
/**

0 commit comments

Comments
 (0)