Check in all entries for context

This commit is contained in:
RMidhunSuresh 2022-01-11 14:57:22 +05:30
parent 73733ce145
commit 5c1813888c

View file

@ -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;