From 5c1813888c352856181025533d6aa68eba5820d8 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 11 Jan 2022 14:57:22 +0530 Subject: [PATCH] Check in all entries for context --- src/matrix/room/timeline/Timeline.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/matrix/room/timeline/Timeline.js b/src/matrix/room/timeline/Timeline.js index 3c1d8236..c5fc98a2 100644 --- a/src/matrix/room/timeline/Timeline.js +++ b/src/matrix/room/timeline/Timeline.js @@ -337,12 +337,12 @@ export class Timeline { } /** - * Fetches an entry with the given event-id from remoteEntries or contextEntriesNotInTimeline. + * Fetches an entry with the given event-id from localEntries, remoteEntries or contextEntriesNotInTimeline. * @param {string} eventId event-id of the entry * @returns entry if found, undefined otherwise */ _findLoadedEventById(eventId) { - return this.getByEventId(eventId) ?? this._contextEntriesNotInTimeline.get(eventId); + return this.getFromAllEntriesById(eventId) ?? this._contextEntriesNotInTimeline.get(eventId); } async _getEventFromStorage(eventId) { @@ -421,6 +421,16 @@ export class Timeline { return null; } + getFromAllEntriesById(eventId) { + for (let i = 0; i < this.entries.length; i += 1) { + const entry = this.entries.get(i); + if (entry.id === eventId) { + return entry; + } + } + return null; + } + /** @public */ get entries() { return this._allEntries;