Skip to content

Commit

Permalink
Only add local receipt if it's after existing receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
andybalaam committed May 24, 2023
1 parent 063d69e commit 9581fbb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/models/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,16 @@ export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {
): void => {
// Add a synthesized receipt when paginating forward in the timeline
if (!toStartOfTimeline) {
room!.addLocalEchoReceipt(event.getSender()!, event, ReceiptType.Read);
const sender = event.getSender();
if (sender) {
const existingReceipt = this.getReadReceiptForUserId(sender);
const existingTimespace = existingReceipt?.data?.ts ?? 0;
const recursionSupport =
this.client.canSupport.get(Feature.RelationsRecursion) ?? ServerSupport.Unsupported;
if (recursionSupport === ServerSupport.Unsupported && existingTimespace < event.getTs()) {
room!.addLocalEchoReceipt(event.getSender()!, event, ReceiptType.Read);
}
}
}
this.onEcho(event, toStartOfTimeline ?? false);
};
Expand Down

0 comments on commit 9581fbb

Please sign in to comment.