Skip to content

Fix edge cases around RR calculations #2160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/models/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2083,12 +2083,12 @@ export class Room extends EventEmitter {

const pair = this.receipts[receiptType][userId];

const existingMatchingReceipt = fake ? pair[ReceiptPairSyntheticIndex] : pair[ReceiptPairRealIndex];
if (existingMatchingReceipt) {
const existingReceipt = pair[ReceiptPairSyntheticIndex] ?? pair[ReceiptPairRealIndex];
if (existingReceipt) {
// we only want to add this receipt if we think it is later than the one we already have.
// This is managed server-side, but because we synthesize RRs locally we have to do it here too.
const ordering = this.getUnfilteredTimelineSet().compareEventOrdering(
existingMatchingReceipt.eventId, eventId);
existingReceipt.eventId, eventId);
if (ordering !== null && ordering >= 0) {
return;
}
Expand All @@ -2100,7 +2100,6 @@ export class Room extends EventEmitter {
};

// we don't bother caching just real receipts by event ID as there's nothing that would read it.
const existingReceipt = pair[ReceiptPairSyntheticIndex] ?? pair[ReceiptPairRealIndex];
if (existingReceipt && this.receiptCacheByEventId[existingReceipt.eventId]) {
const previousEventId = existingReceipt.eventId;
// Remove the receipt we're about to clobber out of existence from the cache
Expand Down