loadNewer method

Future<List<SessionRecord>> loadNewer({
  1. int maxRecords = defaultChunkRecords,
  2. int maxBytes = defaultChunkBytes,
})

Pages one chunk of records back in BELOW the window — the page-down path after deep paging slid the newest side out. Returns the records that rejoin the active branch at the bottom, oldest-first (the transcript delta to append).

Implementation

Future<List<SessionRecord>> loadNewer({
  int maxRecords = defaultChunkRecords,
  int maxBytes = defaultChunkBytes,
}) async {
  final chunk = await _reader.readForward(
    _knownFileBytes,
    maxRecords: maxRecords,
    maxBytes: maxBytes,
  );
  if (chunk.isEmpty) {
    _belowCount = 0;
    return const [];
  }
  _indexChunk(chunk);
  _knownFileBytes = chunk.endOffset;
  if (_belowCount != null) {
    // 0x80000000 == the VM value of `1 << 31`; the shift form is negative
    // on dart2js and would throw inside clamp (issue #1074).
    _belowCount = (_belowCount! - chunk.entries.length).clamp(0, 0x80000000);
  }
  if (chunk.endOffset >= _fileSize) _belowCount = 0;
  final joined = _joinBranchDownward(chunk);
  _evictToBound(newestSide: false);
  return joined;
}