fix: Resolve all audit issues from project readiness review

Blockers:
- IYmtgTests: replace ScannerViewModel() (no-arg init removed) with CollectionViewModel() in testViewModelFiltering and testPortfolioCalculation
- IYmtgTests: fix property access — scannedList, librarySearchText, filteredList, portfolioValue all live on CollectionViewModel, not ScannerViewModel; inject test data after async init settles

Major:
- ContentView: update .onChange(of:) to two-parameter closure syntax (iOS 17 deprecation)
- ModelManager: add missing import FirebaseCore so FirebaseApp.app() resolves explicitly
- CollectionViewModel.deleteCard: call CloudEngine.delete(card:) to remove Firebase entry when a card is deleted (prevents data accumulation)
- CloudEngine: remove never-called batchUpdatePrices() — full backup already handled by backupAllToFirebase()

Minor:
- CardDetailView: move to Features/CardDetail/CardDetailView.swift; remove from ContentView.swift
- Delete PersistenceActor.swift placeholder (superseded by PersistenceController.swift)
- AppConfig.validate(): broaden placeholder-email guard to catch empty strings and common fake domains
- ModelManager: document OTA restart requirement in code comment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 20:22:45 -05:00
parent e18a1080de
commit 13753359b3
8 changed files with 125 additions and 145 deletions

View File

@@ -46,25 +46,4 @@ class CloudEngine {
} catch { print("Cloud Delete Error: \(error)") }
}
static func batchUpdatePrices(cards: [SavedCard]) async {
guard let db = db, let uid = Auth.auth().currentUser?.uid else { return }
let ref = db.collection("users").document(uid).collection("inventory")
let chunks = stride(from: 0, to: cards.count, by: 400).map { Array(cards[$0..<min($0 + 400, cards.count)]) }
for chunk in chunks {
let batch = db.batch()
for card in chunk {
let data: [String: Any] = [
"val": card.currentValuation ?? 0.0,
"curr": card.currencyCode ?? "USD",
"rarity": card.rarity ?? "",
"colors": card.colorIdentity ?? []
]
batch.setData(data, forDocument: ref.document(card.id.uuidString), merge: true)
}
do {
try await batch.commit()
} catch { print("Batch Update Error: \(error)") }
}
}
}

View File

@@ -1,5 +1,6 @@
import CoreML
import Vision
import FirebaseCore
import FirebaseStorage
struct SharedEngineResources {
@@ -7,6 +8,10 @@ struct SharedEngineResources {
}
// MARK: - MODEL MANAGER (OTA Updates)
// Downloads updated .mlmodel files from Firebase Storage and compiles them to Documents/models/.
// IMPORTANT: Each engine (FoilEngine, ConditionEngine, etc.) loads its model via a `static var`
// that is evaluated once at class-load time. A downloaded update will NOT take effect until the
// app is restarted. Inform users via release notes when a model update has been pushed OTA.
class ModelManager {
static let shared = ModelManager()
private let defaults = UserDefaults.standard