From f5fadf700eddba791e9ef54989a6b0e847c3b776 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 13 Dec 2021 12:45:17 +0530 Subject: [PATCH] Move event to remoteEntries if needed --- src/matrix/room/timeline/Timeline.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/matrix/room/timeline/Timeline.js b/src/matrix/room/timeline/Timeline.js index f58e7b83..1b980fee 100644 --- a/src/matrix/room/timeline/Timeline.js +++ b/src/matrix/room/timeline/Timeline.js @@ -251,6 +251,7 @@ export class Timeline { addEntries(newEntries) { this._addLocalRelationsToNewRemoteEntries(newEntries); this._updateFetchedEntries(newEntries); + this._moveFetchedEntryToRemoteEntries(newEntries); this._loadRelatedEvents(newEntries); this._remoteEntries.setManySorted(newEntries); } @@ -266,6 +267,17 @@ export class Timeline { } } + _moveFetchedEntryToRemoteEntries(entries) { + // if some entry in entries is also in fetchedEntries, we need to remove it from fetchedEntries + for (const entry of entries) { + const fetchedEntry = this._fetchedEventEntries.get(entry.id); + if (fetchedEntry) { + fetchedEntry.dependents.forEach(e => e.setContextEntry(entry)); + entry.updateFrom(fetchedEntry); + } + } + } + _updateEntry(entry) { const txnId = entry.isPending ? entry.id : null; const eventId = entry.isPending ? null : entry.id;