getLatestSnapshotMetadata method

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

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(null, sessionId);
  // Pointer read then the leaf's metadata: two single-document reads, no
  // transaction and no state reconstruction.
  final pointerSnap = await _pointersCol(context).doc(sessionId).get();
  if (!pointerSnap.exists) return null;
  final pointer = _PointerDoc.fromData(pointerSnap.data()!);
  return getSnapshotMetadata(pointer.currentSnapshotId, context: context);
}