getLatestSnapshotMetadata method

  1. @override
Future<SessionSnapshot?> getLatestSnapshotMetadata(
  1. String sessionId, {
  2. Map<String, dynamic>? context,
})
override

SessionStore.getSnapshot by sessionId (the session's latest leaf) without the state: the same resolution, the same null-if-none contract, and a row with state null. The resolved sessionId is carried on the returned row even for a row that stored it only under state.

Implementation

@override
Future<SessionSnapshot?> getLatestSnapshotMetadata(
  String sessionId, {
  Map<String, dynamic>? context,
}) async {
  normalizeGetSnapshotOptions(sessionId: sessionId);
  final owned = <SessionSnapshot>[];
  for (final snap in _snapshots.values) {
    if (snapshotSessionId(snap) == sessionId) {
      owned.add(snap);
    }
  }
  final leaf = selectLeafSnapshot(
    owned,
    sessionId,
    rejectBranching: rejectBranchingSessions,
  );
  return leaf != null ? stripSnapshotState(leaf) : null;
}