From 42b3b73551261d1251fe39847e7d41e8804b7a17 Mon Sep 17 00:00:00 2001 From: Germain Date: Wed, 16 Mar 2022 00:59:12 +0000 Subject: [PATCH] Fix threads reply count sometimes off by one (#2240) --- src/models/thread.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/models/thread.ts b/src/models/thread.ts index d2ccefbc1..7d735a915 100644 --- a/src/models/thread.ts +++ b/src/models/thread.ts @@ -191,7 +191,10 @@ export class Thread extends TypedEventEmitter { // There is a risk that the `localTimestamp` approximation will not be accurate // when threads are used over federation. That could results in the reply // count value drifting away from the value returned by the server - if (!this.lastEvent || (isThreadReply && event.localTimestamp > this.lastEvent.localTimestamp)) { + if (!this.lastEvent || (isThreadReply + && (event.getId() !== this.lastEvent.getId()) + && (event.localTimestamp > this.lastEvent.localTimestamp)) + ) { this.lastEvent = event; if (this.lastEvent.getId() !== this.id) { // This counting only works when server side support is enabled