mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-23 17:26:17 +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.
|
/// Save/restore of the crash-recovery session blob and break bookkeeping.
|
||||||
extension _WorkoutScreenSession on _WorkoutScreenState {
|
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 {
|
Future<void> _loadExerciseStates() async {
|
||||||
final states = await StorageService.instance.getAllExerciseStates();
|
final storage = StorageService.instance;
|
||||||
final gapDeloads = await StorageService.instance.activeGapDeloads();
|
final states = await storage.getAllExerciseStates();
|
||||||
// After, not beside, the read above: the push below carries both.
|
// After, not beside, the read above: the push below carries both.
|
||||||
await _cues.load();
|
await _cues.load();
|
||||||
if (mounted) {
|
if (!mounted) return;
|
||||||
_applyBreakState(() {
|
_applyBreakState(() {
|
||||||
_exerciseStates = {for (final s in states) s.name: s};
|
_exerciseStates = {for (final s in states) s.name: s};
|
||||||
_gapDeloads = gapDeloads;
|
});
|
||||||
});
|
// The first snapshot can go out before this load lands, and it would
|
||||||
// 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
|
||||||
// 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.
|
||||||
// service has not started yet: start() builds its own, current one.
|
unawaited(_breaks.push(_buildSnapshot()));
|
||||||
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
|
/// The newest gap or backfill deload per exercise that no session has
|
||||||
/// followed yet: what the tile shows struck through.
|
/// followed yet: what the tile shows struck through.
|
||||||
Future<Map<String, ProgressionEvent>> activeGapDeloads() async {
|
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 marks = await sessionMarks();
|
||||||
final shown = <String, ProgressionEvent>{};
|
final shown = <String, ProgressionEvent>{};
|
||||||
for (final e in await getProgressionEvents()) {
|
for (final e in events) {
|
||||||
if (e.kind != kGapDeloadKind && e.kind != kBackfillDeloadKind) continue;
|
|
||||||
if (shown.containsKey(e.exercise)) continue; // newest first
|
if (shown.containsKey(e.exercise)) continue; // newest first
|
||||||
final history = marks[e.exercise];
|
final history = marks[e.exercise];
|
||||||
if (history != null &&
|
if (history != null &&
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user