fix: codebase audit fixes — safety, accessibility, and production hygiene

Address 16 issues from external audit:
- Move StoreKit transaction listener ownership to StoreManager singleton with proper deinit
- Remove noisy VoiceOver announcements, add missing accessibility on StatPill and BootstrapLoadingView
- Replace String @retroactive Identifiable with IdentifiableShareCode wrapper
- Add crash guard in AchievementEngine getContributingVisitIds + cache stadium lookups
- Pre-compute GamesHistoryViewModel filtered properties to avoid redundant SwiftUI recomputation
- Remove force-unwraps in ProgressMapView with safe guard-let fallback
- Add diff-based update gating in ItineraryTableViewWrapper to prevent unnecessary reloads
- Replace deprecated UIScreen.main with UIWindowScene lookup
- Add deinit task cancellation in ScheduleViewModel and SuggestedTripsGenerator
- Wrap ~234 unguarded print() calls across 27 files in #if DEBUG

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-22 00:07:53 -06:00
parent 826eadbc0f
commit 91c5eac22d
32 changed files with 434 additions and 67 deletions

View File

@@ -73,22 +73,33 @@ final class StoreManager {
products.first { $0.id == "com.88oakapps.SportsTime.pro.annual2" }
}
// MARK: - Transaction Listener
nonisolated(unsafe) private var transactionListenerTask: Task<Void, Never>?
// MARK: - Initialization
private init() {}
deinit {
transactionListenerTask?.cancel()
}
// MARK: - Product Loading
func loadProducts() async {
isLoading = true
error = nil
#if DEBUG
print("[StoreManager] Loading products for IDs: \(Self.proProductIDs)")
#endif
do {
let fetchedProducts = try await Product.products(for: Self.proProductIDs)
products = fetchedProducts
#if DEBUG
print("[StoreManager] Loaded \(fetchedProducts.count) products:")
for product in fetchedProducts {
print("[StoreManager] - \(product.id): \(product.displayPrice) (\(product.displayName))")
@@ -101,16 +112,21 @@ final class StoreManager {
}
}
}
#endif
// Treat an empty fetch as a configuration issue so UI can show a useful fallback.
if fetchedProducts.isEmpty {
#if DEBUG
print("[StoreManager] WARNING: No products returned — check Configuration.storekit")
#endif
error = .productNotFound
}
} catch {
products = []
self.error = .productNotFound
#if DEBUG
print("[StoreManager] ERROR loading products: \(error)")
#endif
}
isLoading = false
@@ -289,10 +305,11 @@ final class StoreManager {
return "unknown"
}
// MARK: - Transaction Listener
// MARK: - Transaction Listening
func listenForTransactions() -> Task<Void, Never> {
Task.detached {
func startListeningForTransactions() {
transactionListenerTask?.cancel()
transactionListenerTask = Task.detached {
for await result in Transaction.updates {
if case .verified(let transaction) = result {
await transaction.finish()