From 57c4070505d2e847a066abfb9927f70c373b3d79 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 9 Sep 2021 11:30:19 -0700 Subject: [PATCH] Fetch event from server if not in storage --- src/matrix/room/BaseRoom.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/matrix/room/BaseRoom.js b/src/matrix/room/BaseRoom.js index c8afc3d3..ab82ff74 100644 --- a/src/matrix/room/BaseRoom.js +++ b/src/matrix/room/BaseRoom.js @@ -555,8 +555,13 @@ export class BaseRoom extends EventEmitter { const observable = this._observedEvents.observe(eventId, entry); if (!entry) { // update in the background - this._readEventById(eventId).then(entry => { - observable.update(entry); + this._readEventById(eventId).then(async entry => { + if (entry) { + observable.update(entry); + } else { + const fectchedEntry = await this._fetchContext(eventId); + observable.update(fectchedEntry); + } }).catch(err => { console.warn(`could not load event ${eventId} from storage`, err); });