diff --git a/src/matrix/room/timeline/EventKey.ts b/src/matrix/room/timeline/EventKey.ts index 8775df26..8f1e17da 100644 --- a/src/matrix/room/timeline/EventKey.ts +++ b/src/matrix/room/timeline/EventKey.ts @@ -25,11 +25,6 @@ export class EventKey { ) { } - nextFragmentKey(): EventKey { - // could take MIN_EVENT_INDEX here if it can't be paged back - return new EventKey(this.fragmentId + 1, KeyLimits.middleStorageKey); - } - nextKeyForDirection(direction: Direction): EventKey { if (direction.isForward) { return this.nextKey(); diff --git a/src/matrix/room/timeline/persistence/SyncWriter.js b/src/matrix/room/timeline/persistence/SyncWriter.js index 1ee2ce7d..8fd9d16a 100644 --- a/src/matrix/room/timeline/persistence/SyncWriter.js +++ b/src/matrix/room/timeline/persistence/SyncWriter.js @@ -124,7 +124,8 @@ export class SyncWriter { } else if (timeline.limited) { // replace live fragment for limited sync, *only* if we had a live fragment already const oldFragmentId = currentKey.fragmentId; - currentKey = currentKey.nextFragmentKey(); + const maxFragmentId = await txn.timelineFragments.getMaxFragmentId(this._roomId); + currentKey = EventKey.defaultFragmentKey(maxFragmentId + 1); const {oldFragment, newFragment} = await this._replaceLiveFragment(oldFragmentId, currentKey.fragmentId, timeline.prev_batch, txn); entries.push(FragmentBoundaryEntry.end(oldFragment, this._fragmentIdComparer)); entries.push(FragmentBoundaryEntry.start(newFragment, this._fragmentIdComparer));