From 73733ce145ababc3e1a86d22d98c8603114b5152 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 11 Jan 2022 14:49:59 +0530 Subject: [PATCH] Guard entry from storage being processed by method --- src/matrix/room/timeline/Timeline.js | 2 +- src/matrix/room/timeline/entries/NonPersistedEventEntry.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/matrix/room/timeline/Timeline.js b/src/matrix/room/timeline/Timeline.js index acc2af77..3c1d8236 100644 --- a/src/matrix/room/timeline/Timeline.js +++ b/src/matrix/room/timeline/Timeline.js @@ -274,7 +274,7 @@ export class Timeline { */ for (const entry of entries) { const relatedEntry = this._contextEntriesNotInTimeline.get(entry.relatedEventId); - if (relatedEntry?.addRelation(entry)) { + if (relatedEntry?.isNonPersisted && relatedEntry?.addRelation(entry)) { // update other entries for which this entry is a context entry relatedEntry.contextForEntries?.forEach(e => { this._remoteEntries.findAndUpdate(te => te.id === e.id, () => "contextEntry"); diff --git a/src/matrix/room/timeline/entries/NonPersistedEventEntry.js b/src/matrix/room/timeline/entries/NonPersistedEventEntry.js index 8ec9f72e..cb8df8a3 100644 --- a/src/matrix/room/timeline/entries/NonPersistedEventEntry.js +++ b/src/matrix/room/timeline/entries/NonPersistedEventEntry.js @@ -27,4 +27,8 @@ export class NonPersistedEventEntry extends EventEntry { get entryIndex() { throw new Error("Cannot access entryIndex for non-persisted EventEntry"); } + + get isNonPersisted() { + return true; + } }