Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions SleepFocus/Services/HomeSummaryStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,26 @@ final class HomeSummaryStore: ObservableObject {
resolvedSummary = syncedSummary
summary = syncedSummary
}

// Health data was just uploaded. If the score pipeline was not already
// triggered before the sync (e.g. because no summary existed yet),
// trigger it now so the backend can compute the score.
if !onDemandTriggerResult.attemptedScore, resolvedSummary != nil {
let postSyncTriggerResult = await triggerOnDemandPipelinesIfNeeded(
using: authManager,
for: selectedDate,
summary: resolvedSummary
)
if postSyncTriggerResult.attemptedAny {
invalidateMonthCache(monthKey: selectedMonthKey)
guard isActiveLoad(loadToken) else { return }
if let refreshedSummary = await fetchSummary(using: authManager, for: selectedDate) {
cacheSummary(refreshedSummary, fallbackDate: selectedDate)
resolvedSummary = refreshedSummary
summary = refreshedSummary
}
}
}
}

if let currentSummary = resolvedSummary,
Expand Down
Loading