Stabilize iOS/watchOS/tvOS apps and add cross-platform audit remediation

This commit is contained in:
Trey t
2026-02-11 12:54:40 -06:00
parent e40275e694
commit acce712261
77 changed files with 2940 additions and 765 deletions

View File

@@ -7,6 +7,7 @@
import SwiftUI
import HealthKit
import SharedCore
struct CompletedWorkoutView: View {
@ObservedObject var bridgeModule = BridgeModule.shared
@@ -15,6 +16,9 @@ struct CompletedWorkoutView: View {
@State var notes: String = ""
@State var isUploading: Bool = false
@State var gettingHealthKitData: Bool = false
@State private var hasError = false
@State private var errorMessage = ""
private let runtimeReporter = RuntimeReporter.shared
var postData: [String: Any]
let healthKitHelper = HealthKitHelper()
@@ -60,7 +64,6 @@ struct CompletedWorkoutView: View {
Spacer()
Button("Upload", action: {
isUploading = true
upload(postBody: postData)
})
.frame(maxWidth: .infinity, alignment: .center)
@@ -70,11 +73,14 @@ struct CompletedWorkoutView: View {
.cornerRadius(Constants.buttonRadius)
.padding()
.frame(maxWidth: .infinity)
.disabled(isUploading || gettingHealthKitData)
}
.padding([.leading, .trailing])
}
.onAppear{
bridgeModule.sendWorkoutCompleteToWatch()
.alert("Upload Failed", isPresented: $hasError) {
Button("OK", role: .cancel) {}
} message: {
Text(errorMessage)
}
// .onChange(of: bridgeModule.healthKitUUID, perform: { healthKitUUID in
// if let healthKitUUID = healthKitUUID {
@@ -92,6 +98,11 @@ struct CompletedWorkoutView: View {
}
func upload(postBody: [String: Any]) {
guard isUploading == false else {
return
}
isUploading = true
var _postBody = postBody
_postBody["difficulty"] = difficulty
_postBody["notes"] = notes
@@ -103,6 +114,7 @@ struct CompletedWorkoutView: View {
switch result {
case .success(_):
DispatchQueue.main.async {
self.isUploading = false
bridgeModule.resetCurrentWorkout()
dismiss()
completedWorkoutDismissed?(true)
@@ -110,8 +122,13 @@ struct CompletedWorkoutView: View {
case .failure(let failure):
DispatchQueue.main.async {
self.isUploading = false
self.errorMessage = failure.localizedDescription
self.hasError = true
}
print(failure)
runtimeReporter.recordError(
"Completed workout upload failed",
metadata: ["error": failure.localizedDescription]
)
}
})
}