fix(analytics): mark WorkoutSnapshot.init(vm:) @MainActor

Build error (Xcode, Swift 6 strict concurrency): WorkoutSnapshot.init(vm:) read
history/workoutDates/schedule/missedDates from @MainActor WorkoutViewModel in a
nonisolated init. The init is only ever called from AnalyticsService.reconcile
(@MainActor) — mark it @MainActor to match its actual call site.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
kutesir
2026-07-08 10:44:31 +03:00
committed by kutesir
parent b4813272f6
commit 764e1c2f3d

View File

@@ -36,7 +36,7 @@ final class AnalyticsService: ObservableObject {
var healthByDate: [String: RawHealthDay] = [:] // HealthKit reference var healthByDate: [String: RawHealthDay] = [:] // HealthKit reference
init() {} init() {}
init(vm: WorkoutViewModel) { @MainActor init(vm: WorkoutViewModel) {
self.logByDate = Dictionary(vm.history.map { ($0.date, $0) }, uniquingKeysWith: { a, _ in a }) self.logByDate = Dictionary(vm.history.map { ($0.date, $0) }, uniquingKeysWith: { a, _ in a })
self.workoutDates = Set(vm.workoutDates) self.workoutDates = Set(vm.workoutDates)
self.scheduledWeekdays = Set(vm.schedule.keys) self.scheduledWeekdays = Set(vm.schedule.keys)