streak function

  1. @riverpod
Future<int> streak(
  1. Ref<Object?> ref
)

Implementation

@riverpod
Future<int> streak(Ref ref) async {
  final ds = ref.watch(supabaseDatasourceProvider);
  final dates = await ds.getSessionDates();
  final value = StreakCalculator.currentStreak(dates);
  // Cache for next cold-start so the streak hero card renders the real
  // number on first frame instead of "0 — Plant a streak."
  unawaited(ref.read(userPrefsDatasourceProvider).setCachedStreak(value));
  return value;
}