mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-21 09:12:18 +01:00
Load gap deload marks after the snapshot push
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9b50d95386
commit
394ff70dc5
@ -8,21 +8,24 @@ part of 'workout_screen.dart';
|
||||
|
||||
/// Save/restore of the crash-recovery session blob and break bookkeeping.
|
||||
extension _WorkoutScreenSession on _WorkoutScreenState {
|
||||
/// Loads every exercise's state and the gap deloads to show.
|
||||
/// Loads every exercise's state, then the gap deloads to show.
|
||||
Future<void> _loadExerciseStates() async {
|
||||
final states = await StorageService.instance.getAllExerciseStates();
|
||||
final gapDeloads = await StorageService.instance.activeGapDeloads();
|
||||
final storage = StorageService.instance;
|
||||
final states = await storage.getAllExerciseStates();
|
||||
// After, not beside, the read above: the push below carries both.
|
||||
await _cues.load();
|
||||
if (mounted) {
|
||||
_applyBreakState(() {
|
||||
_exerciseStates = {for (final s in states) s.name: s};
|
||||
_gapDeloads = gapDeloads;
|
||||
});
|
||||
// The first snapshot can go out before this load lands, and it would
|
||||
// count a paused exercise's sets until the next tap. A no-op if the
|
||||
// service has not started yet: start() builds its own, current one.
|
||||
unawaited(_breaks.push(_buildSnapshot()));
|
||||
if (!mounted) return;
|
||||
_applyBreakState(() {
|
||||
_exerciseStates = {for (final s in states) s.name: s};
|
||||
});
|
||||
// The first snapshot can go out before this load lands, and it would
|
||||
// count a paused exercise's sets until the next tap. A no-op if the
|
||||
// service has not started yet: start() builds its own, current one.
|
||||
unawaited(_breaks.push(_buildSnapshot()));
|
||||
// Last, and only for the tiles: the struck-through pre-deload targets.
|
||||
final gapDeloads = await storage.activeGapDeloads();
|
||||
if (mounted && gapDeloads.isNotEmpty) {
|
||||
_applyBreakState(() => _gapDeloads = gapDeloads);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -120,10 +120,15 @@ extension StorageServiceGapDeload on StorageService {
|
||||
/// The newest gap or backfill deload per exercise that no session has
|
||||
/// followed yet: what the tile shows struck through.
|
||||
Future<Map<String, ProgressionEvent>> activeGapDeloads() async {
|
||||
final events = [
|
||||
for (final e in await getProgressionEvents())
|
||||
if (e.kind == kGapDeloadKind || e.kind == kBackfillDeloadKind) e,
|
||||
];
|
||||
// The usual case: no gap deload ever, so no history scan.
|
||||
if (events.isEmpty) return const {};
|
||||
final marks = await sessionMarks();
|
||||
final shown = <String, ProgressionEvent>{};
|
||||
for (final e in await getProgressionEvents()) {
|
||||
if (e.kind != kGapDeloadKind && e.kind != kBackfillDeloadKind) continue;
|
||||
for (final e in events) {
|
||||
if (shown.containsKey(e.exercise)) continue; // newest first
|
||||
final history = marks[e.exercise];
|
||||
if (history != null &&
|
||||
|
||||
Loading…
Reference in New Issue
Block a user