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:
@@ -47,8 +47,10 @@ final class PhotoImportViewModel {
|
||||
func processSelectedPhotos(_ items: [PhotosPickerItem]) async {
|
||||
guard !items.isEmpty else { return }
|
||||
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] ════════════════════════════════════════════════")
|
||||
print("📷 [PhotoImport] Starting photo import with \(items.count) items")
|
||||
#endif
|
||||
|
||||
isProcessing = true
|
||||
totalCount = items.count
|
||||
@@ -61,16 +63,21 @@ final class PhotoImportViewModel {
|
||||
var assets: [PHAsset] = []
|
||||
|
||||
for (index, item) in items.enumerated() {
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] ────────────────────────────────────────────────")
|
||||
print("📷 [PhotoImport] Processing item \(index + 1)/\(items.count)")
|
||||
print("📷 [PhotoImport] Item identifier: \(item.itemIdentifier ?? "nil")")
|
||||
print("📷 [PhotoImport] Item supportedContentTypes: \(item.supportedContentTypes)")
|
||||
#endif
|
||||
|
||||
if let assetId = item.itemIdentifier {
|
||||
let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil)
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] PHAsset fetch result count: \(fetchResult.count)")
|
||||
#endif
|
||||
|
||||
if let asset = fetchResult.firstObject {
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] ✅ Found PHAsset")
|
||||
print("📷 [PhotoImport] - localIdentifier: \(asset.localIdentifier)")
|
||||
print("📷 [PhotoImport] - mediaType: \(asset.mediaType.rawValue)")
|
||||
@@ -79,22 +86,30 @@ final class PhotoImportViewModel {
|
||||
print("📷 [PhotoImport] - sourceType: \(asset.sourceType.rawValue)")
|
||||
print("📷 [PhotoImport] - pixelWidth: \(asset.pixelWidth)")
|
||||
print("📷 [PhotoImport] - pixelHeight: \(asset.pixelHeight)")
|
||||
#endif
|
||||
assets.append(asset)
|
||||
} else {
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] ⚠️ No PHAsset found for identifier")
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] ⚠️ No itemIdentifier on PhotosPickerItem")
|
||||
#endif
|
||||
}
|
||||
processedCount += 1
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] ────────────────────────────────────────────────")
|
||||
print("📷 [PhotoImport] Loaded \(assets.count) PHAssets, extracting metadata...")
|
||||
#endif
|
||||
|
||||
// Extract metadata from all assets
|
||||
let metadataList = await metadataExtractor.extractMetadata(from: assets)
|
||||
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] ────────────────────────────────────────────────")
|
||||
print("📷 [PhotoImport] Extracted \(metadataList.count) metadata records")
|
||||
|
||||
@@ -103,25 +118,32 @@ final class PhotoImportViewModel {
|
||||
let withDate = metadataList.filter { $0.hasValidDate }.count
|
||||
print("📷 [PhotoImport] Photos with location: \(withLocation)/\(metadataList.count)")
|
||||
print("📷 [PhotoImport] Photos with date: \(withDate)/\(metadataList.count)")
|
||||
#endif
|
||||
|
||||
// Process each photo through game matcher
|
||||
processedCount = 0
|
||||
for (index, metadata) in metadataList.enumerated() {
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] Matching photo \(index + 1): date=\(metadata.captureDate?.description ?? "nil"), location=\(metadata.hasValidLocation)")
|
||||
#endif
|
||||
let candidate = await gameMatcher.processPhotoForImport(metadata: metadata)
|
||||
processedPhotos.append(candidate)
|
||||
|
||||
// Auto-confirm high-confidence matches
|
||||
if candidate.canAutoProcess {
|
||||
confirmedImports.insert(candidate.id)
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] ✅ Auto-confirmed match")
|
||||
#endif
|
||||
}
|
||||
|
||||
processedCount += 1
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
print("📷 [PhotoImport] ════════════════════════════════════════════════")
|
||||
print("📷 [PhotoImport] Import complete: \(processedPhotos.count) photos, \(confirmedImports.count) auto-confirmed")
|
||||
#endif
|
||||
|
||||
isProcessing = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user