diff --git a/Shared/Views/InsightsView/InsightsView.swift b/Shared/Views/InsightsView/InsightsView.swift index 45a844d..dea7c7f 100644 --- a/Shared/Views/InsightsView/InsightsView.swift +++ b/Shared/Views/InsightsView/InsightsView.swift @@ -293,7 +293,7 @@ struct InsightsView: View { private var isGeneratingInsights: Bool { let states = [viewModel.monthLoadingState, viewModel.yearLoadingState, viewModel.allTimeLoadingState] - return states.contains(where: { $0 == .loading || $0 == .idle }) + return states.contains(where: { $0 == .loading }) } private var generatingOverlay: some View { diff --git a/Shared/Views/InsightsView/InsightsViewModel.swift b/Shared/Views/InsightsView/InsightsViewModel.swift index 500f024..c6e441b 100644 --- a/Shared/Views/InsightsView/InsightsViewModel.swift +++ b/Shared/Views/InsightsView/InsightsViewModel.swift @@ -132,6 +132,12 @@ class InsightsViewModel: ObservableObject { } } + // Set all states to loading upfront so the overlay dismisses + // as soon as all tasks complete (not one-by-one) + monthLoadingState = .loading + yearLoadingState = .loading + allTimeLoadingState = .loading + // Generate insights concurrently for all three periods await withTaskGroup(of: Void.self) { group in group.addTask { @MainActor in