Skip to content

fix: statistics summaries not calculating on initial view load#698

Merged
dnzxy merged 1 commit intonightscout:devfrom
Sjoerd-Bo3:fix/statistics-timing-issue-687
Aug 11, 2025
Merged

fix: statistics summaries not calculating on initial view load#698
dnzxy merged 1 commit intonightscout:devfrom
Sjoerd-Bo3:fix/statistics-timing-issue-687

Conversation

@Sjoerd-Bo3
Copy link
Contributor

@Sjoerd-Bo3 Sjoerd-Bo3 commented Jul 5, 2025

Summary

  • Fixes timing issue where statistics summaries show 0 values on initial view load
  • Defers summary calculations with DispatchQueue.main.async in onAppear
  • Uses MainActor.run for onChange(selectedInterval) to ensure proper sequencing

Test plan

  • Open Statistics tab
  • Verify summaries show correct values immediately (not 0)
  • Change time intervals and verify summaries update correctly
  • Test on Meal, TDD, and Bolus statistics views

Related to #687 - this addresses the secondary timing issue discovered during testing.

…l view load

- Add DispatchQueue.main.async to defer summary calculations in onAppear
- Use MainActor.run for onChange(of: selectedInterval) to ensure scroll position updates before calculations
- Applies to MealStatsView, BolusStatsView, and TotalDailyDoseChart
- Fixes issue where summaries showed 0 until user interacted with chart
@Sjoerd-Bo3 Sjoerd-Bo3 changed the title Fix statistics summaries not calculating on initial view load fix: statistics summaries not calculating on initial view load Jul 5, 2025
@Sjoerd-Bo3 Sjoerd-Bo3 changed the base branch from main to dev July 5, 2025 16:44
@mountrcg
Copy link
Contributor

mountrcg commented Jul 7, 2025

Tested on TDD, now no fine tuning is needed anymore for the daily stats. It is aligned on full current day on first popup.

@Sjoerd-Bo3 Sjoerd-Bo3 self-assigned this Jul 7, 2025
@dnzxy dnzxy merged commit 8f14ab8 into nightscout:dev Aug 11, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants