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 Foundation
import SwiftUI
import SharedCore
class DataStore: ObservableObject {
enum DataStoreStatus {
@@ -15,6 +16,7 @@ class DataStore: ObservableObject {
}
static let shared = DataStore()
private let runtimeReporter = RuntimeReporter.shared
public private(set) var allWorkouts: [Workout]?
public private(set) var allMuscles: [Muscle]?
@@ -23,8 +25,7 @@ class DataStore: ObservableObject {
public private(set) var allNSFWVideos: [NSFWVideo]?
@Published public private(set) var status = DataStoreStatus.idle
private let fetchAllDataQueue = DispatchGroup()
private var pendingFetchCompletions = [() -> Void]()
public func randomVideoFor(gender: String) -> String? {
return allNSFWVideos?.filter({
@@ -52,7 +53,15 @@ class DataStore: ObservableObject {
}
public func fetchAllData(completion: @escaping (() -> Void)) {
if status == .loading {
pendingFetchCompletions.append(completion)
runtimeReporter.recordInfo("fetchAllData called while already loading")
return
}
pendingFetchCompletions = [completion]
status = .loading
let fetchAllDataQueue = DispatchGroup()
fetchAllDataQueue.enter()
fetchAllDataQueue.enter()
@@ -62,7 +71,9 @@ class DataStore: ObservableObject {
fetchAllDataQueue.notify(queue: .main) {
self.status = .idle
completion()
let completions = self.pendingFetchCompletions
self.pendingFetchCompletions.removeAll()
completions.forEach { $0() }
}
AllWorkoutFetchable().fetch(completion: { result in
@@ -70,9 +81,9 @@ class DataStore: ObservableObject {
case .success(let model):
self.allWorkouts = model
case .failure(let error):
print(error)
self.runtimeReporter.recordError("Failed to fetch workouts", metadata: ["error": error.localizedDescription])
}
self.fetchAllDataQueue.leave()
fetchAllDataQueue.leave()
})
AllMusclesFetchable().fetch(completion: { result in
@@ -82,9 +93,9 @@ class DataStore: ObservableObject {
$0.name < $1.name
})
case .failure(let error):
print(error)
self.runtimeReporter.recordError("Failed to fetch muscles", metadata: ["error": error.localizedDescription])
}
self.fetchAllDataQueue.leave()
fetchAllDataQueue.leave()
})
AllEquipmentFetchable().fetch(completion: { result in
@@ -94,9 +105,9 @@ class DataStore: ObservableObject {
$0.name < $1.name
})
case .failure(let error):
print(error)
self.runtimeReporter.recordError("Failed to fetch equipment", metadata: ["error": error.localizedDescription])
}
self.fetchAllDataQueue.leave()
fetchAllDataQueue.leave()
})
AllExerciseFetchable().fetch(completion: { result in
@@ -106,9 +117,9 @@ class DataStore: ObservableObject {
$0.name < $1.name
})
case .failure(let error):
print(error)
self.runtimeReporter.recordError("Failed to fetch exercises", metadata: ["error": error.localizedDescription])
}
self.fetchAllDataQueue.leave()
fetchAllDataQueue.leave()
})
AllNSFWVideosFetchable().fetch(completion: { result in
@@ -116,9 +127,9 @@ class DataStore: ObservableObject {
case .success(let model):
self.allNSFWVideos = model
case .failure(let error):
print(error)
self.runtimeReporter.recordError("Failed to fetch NSFW videos", metadata: ["error": error.localizedDescription])
}
self.fetchAllDataQueue.leave()
fetchAllDataQueue.leave()
})
}