Avoid simply incrementing fragment ID to get next fragment

This commit is contained in:
Danila Fedorin 2021-09-08 15:43:02 -07:00
parent 3ce2d0777d
commit 7f91e0c1bd
2 changed files with 2 additions and 6 deletions

View File

@ -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 { nextKeyForDirection(direction: Direction): EventKey {
if (direction.isForward) { if (direction.isForward) {
return this.nextKey(); return this.nextKey();

View File

@ -124,7 +124,8 @@ export class SyncWriter {
} else if (timeline.limited) { } else if (timeline.limited) {
// replace live fragment for limited sync, *only* if we had a live fragment already // replace live fragment for limited sync, *only* if we had a live fragment already
const oldFragmentId = currentKey.fragmentId; 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); const {oldFragment, newFragment} = await this._replaceLiveFragment(oldFragmentId, currentKey.fragmentId, timeline.prev_batch, txn);
entries.push(FragmentBoundaryEntry.end(oldFragment, this._fragmentIdComparer)); entries.push(FragmentBoundaryEntry.end(oldFragment, this._fragmentIdComparer));
entries.push(FragmentBoundaryEntry.start(newFragment, this._fragmentIdComparer)); entries.push(FragmentBoundaryEntry.start(newFragment, this._fragmentIdComparer));