This commit is contained in:
Trey t
2024-07-01 23:30:24 -05:00
parent 5f7c0a40b8
commit cedab87193

View File

@@ -45,11 +45,14 @@ class WatchWorkout: NSObject, ObservableObject, HKWorkoutSessionDelegate, HKLive
func startWorkout() { func startWorkout() {
if isInWorkout { return } if isInWorkout { return }
setupCore()
hkWorkoutSession.startActivity(with: Date()) hkWorkoutSession.startActivity(with: Date())
isInWorkout = true
//WKInterfaceDevice.current().play(.start) //WKInterfaceDevice.current().play(.start)
} }
func stopWorkout(sendDetails: Bool) { func stopWorkout(sendDetails: Bool) {
hkWorkoutSession.endCurrentActivity(on: Date())
hkWorkoutSession.end() hkWorkoutSession.end()
} }
@@ -125,10 +128,13 @@ class WatchWorkout: NSObject, ObservableObject, HKWorkoutSessionDelegate, HKLive
} }
func workoutSession(_ workoutSession: HKWorkoutSession, didFailWithError error: Error) { func workoutSession(_ workoutSession: HKWorkoutSession, didFailWithError error: Error) {
workoutSession.end() print("[didFailWithError] Workout Builder changed event: \(error.localizedDescription)")
setupCore() // trying to go from ended to something so just end it all
startWorkout() if workoutSession.state == .ended {
beginBuilderWorkout() getWorkoutBuilderDetails(completion: {
self.setupCore()
})
}
} }
func workoutBuilder(_ workoutBuilder: HKLiveWorkoutBuilder, didCollectDataOf collectedTypes: Set<HKSampleType>) { func workoutBuilder(_ workoutBuilder: HKLiveWorkoutBuilder, didCollectDataOf collectedTypes: Set<HKSampleType>) {