From 39f141820a9da9116ae508c2aa8dcd77835741bb Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 9 Sep 2021 15:10:07 -0700 Subject: [PATCH] Error on missing tokens and properly set next/previous tokens --- src/matrix/room/timeline/persistence/GapWriter.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/matrix/room/timeline/persistence/GapWriter.js b/src/matrix/room/timeline/persistence/GapWriter.js index 690eec6c..1b2a119d 100644 --- a/src/matrix/room/timeline/persistence/GapWriter.js +++ b/src/matrix/room/timeline/persistence/GapWriter.js @@ -265,6 +265,10 @@ export class GapWriter { throw new Error("Invalid chunks in response"); } + if (!start || !end) { + throw new Error("Context call did not receive start and end tokens"); + } + const eventEntry = await txn.timelineEvents.getByEventId(this._roomId, event.event_id); if (eventEntry) { // If we have the current event, eary return. @@ -281,6 +285,8 @@ export class GapWriter { // No overlapping fragments found. const newFragment = await this._createNewFragment(txn); + newFragment.nextToken = end; + newFragment.previousToken = start; // Pretend that we did find an overlapping entry above, and that this entry is for the new fragment. const newEntry = FragmentBoundaryEntry.end(newFragment, this._fragmentIdComparer); overlapUp.neighbourFragmentEntry = newEntry;