From 8dc3c13a93c48a33633d7a17a920f88d4dcb2576 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 20 Jul 2022 02:27:18 -0500 Subject: [PATCH] Ignore missing events --- src/matrix/room/timeline/Timeline.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/matrix/room/timeline/Timeline.js b/src/matrix/room/timeline/Timeline.js index d76ad147..3700906b 100644 --- a/src/matrix/room/timeline/Timeline.js +++ b/src/matrix/room/timeline/Timeline.js @@ -27,7 +27,7 @@ import {NonPersistedEventEntry} from "./entries/NonPersistedEventEntry.js"; import {EVENT_TYPE as MEMBER_EVENT_TYPE} from "../members/RoomMember.js"; export class Timeline { - constructor({roomId, storage, closeCallback, fragmentIdComparer, pendingEvents, clock, powerLevelsObservable, hsApi}) { + constructor({roomId, storage, closeCallback, fragmentIdComparer, pendingEvents, clock, powerLevelsObservable, hsApi, ignoreMissingEvents}) { this._roomId = roomId; this._storage = storage; this._closeCallback = closeCallback; @@ -50,6 +50,7 @@ export class Timeline { /** Only used to decrypt non-persisted context entries fetched from the homeserver */ this._decryptEntries = null; this._hsApi = hsApi; + this._ignoreMissingEvents = ignoreMissingEvents || false; this.initializePowerLevels(powerLevelsObservable); } @@ -321,18 +322,18 @@ export class Timeline { if (!entry.contextEventId) { continue; } - const id = entry.contextEventId; + const contextEventId = entry.contextEventId; // before looking into remoteEntries, check the entries // that about to be added first - let contextEvent = entries.find(e => e.id === id); + let contextEvent = entries.find(e => e.id === contextEventId); if (!contextEvent) { - contextEvent = this._findLoadedEventById(id); + contextEvent = this._findLoadedEventById(contextEventId); } if (contextEvent) { entry.setContextEntry(contextEvent); // we don't emit an update here, as the add or update // that the callee will emit hasn't been emitted yet. - } else { + } else if(!this._ignoreMissingEvents) { // we don't await here, which is not ideal, // but one of our callers, addEntries, is not async // so there is not much point.