E-4.4b Rewiring: WordeckAPIs decks/cards/reviews-Methoden delegieren jetzt über die @MainActor-Fassade WordeckData an WordeckEventCoordinator (lokaler EventLog + FSRS + sync2) statt an die toten REST-Routen (410). Views/Stores/ GradeQueue/StudySession bleiben unverändert — minimal-invasiv. duplicateDeck + distractors lokal ergänzt (Server-Endpoints kennen event-sourced Karten nicht). configure() beim App-Launch. Marketplace/Generate/Author bleiben REST. Build grün, 48/48 Tests grün. Kompilier-verifiziert — Study-Loop braucht noch Geräte-Verifikation. Offen: Datenmigration vor-Cutover gecachter Decks (CachedDeck→Events). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60 lines
2.1 KiB
Swift
60 lines
2.1 KiB
Swift
import ManaAuthUI
|
|
import ManaCore
|
|
import SwiftData
|
|
import SwiftUI
|
|
|
|
@main
|
|
struct WordeckNativeApp: App {
|
|
let container: ModelContainer
|
|
@State private var auth: AuthClient
|
|
@State private var authGate: ManaAuthGate
|
|
|
|
init() {
|
|
do {
|
|
container = try ModelContainer(
|
|
for: CachedDeck.self,
|
|
CachedCard.self,
|
|
CachedDueReview.self,
|
|
PendingGrade.self
|
|
)
|
|
} catch {
|
|
Log.app.error(
|
|
"ModelContainer-Disk-Init fehlgeschlagen, falle auf in-memory zurück: \(String(describing: error), privacy: .public)"
|
|
)
|
|
// In-memory-Fallback statt Crash: der Offline-Cache ist dann nur
|
|
// für die laufende Session gültig, aber die App startet und der
|
|
// User kann sich anmelden + online lernen.
|
|
do {
|
|
let config = ModelConfiguration(isStoredInMemoryOnly: true)
|
|
container = try ModelContainer(
|
|
for: CachedDeck.self,
|
|
CachedCard.self,
|
|
CachedDueReview.self,
|
|
PendingGrade.self,
|
|
configurations: config
|
|
)
|
|
} catch {
|
|
fatalError("ModelContainer auch in-memory nicht initialisierbar: \(error)")
|
|
}
|
|
}
|
|
let auth = AuthClient(config: AppConfig.manaAppConfig)
|
|
auth.bootstrap()
|
|
_auth = State(initialValue: auth)
|
|
_authGate = State(initialValue: ManaAuthGate(auth: auth))
|
|
// Event-Sync-Coordinator initialisieren (E-4.4b): user-owned-Daten
|
|
// (decks/cards/reviews) laufen jetzt event-sourced über ManaEventSync
|
|
// statt über die toten REST-Routen. Crypto + Sync starten async.
|
|
WordeckEventCoordinator.configure(auth: auth)
|
|
Log.app.info("Wordeck starting — auth status: \(String(describing: auth.status), privacy: .public)")
|
|
}
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
RootView()
|
|
.environment(auth)
|
|
.environment(authGate)
|
|
.tint(WordeckTheme.primary)
|
|
}
|
|
.modelContainer(container)
|
|
}
|
|
}
|