- SnapshotModels.swift: CachedQuote (slug-unique, themes/regions
als CSV), SnapshotMeta (singleton mit lastSyncedAt + totalCount),
SnapshotContainer.make() mit App-Group-Store-URL (Fallback auf
App-Container für Dev ohne Apple-Dev-Portal-Setup)
- SnapshotSync (actor) mit injectable Loader für Tests: refresh /
refreshIfStale / tryRefresh (fail-soft). Re-konsolidiert beim Pull
(Update + Insert + Delete entzogene Slugs). 24h-Staleness-Default.
- DailyQuoteWidget: Hash-of-Day-Picker aus SwiftData, drei Sizes,
Mitternacht-Refresh-Policy, Placeholder bei leerem Store. Widget-
Target zieht SnapshotModels.swift mit (project.yml).
- ZitareNativeApp triggert SnapshotSync.tryRefresh() bei Launch +
WidgetCenter.reloadAllTimelines() danach.
- AppConfig.snapshotURL = webBaseURL/index-min.json (Web-Endpoint
noch nicht live, fail-soft).
- DeepLinkRouter Substring-Guard fix (`/t` statt `/t/` im
Prefix-Array, sonst greift hasPrefix("/t//") nicht).
- 22 Tests grün (6 AppConfig + 11 DeepLinkRouter + 3 SnapshotSync +
1 UI + 1 Widget-Compile-Smoke), swiftlint 0 violations in 22 Files
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
47 lines
1.4 KiB
Swift
47 lines
1.4 KiB
Swift
import ManaCore
|
|
import SwiftData
|
|
import SwiftUI
|
|
import WidgetKit
|
|
|
|
@main
|
|
struct ZitareNativeApp: App {
|
|
@State private var auth: AuthClient
|
|
private let snapshotContainer: ModelContainer?
|
|
|
|
init() {
|
|
let auth = AuthClient(config: AppConfig.manaAppConfig)
|
|
auth.bootstrap()
|
|
_auth = State(initialValue: auth)
|
|
do {
|
|
snapshotContainer = try SnapshotContainer.make()
|
|
} catch {
|
|
Log.snapshot.error(
|
|
"SnapshotContainer init fehlgeschlagen: \(String(describing: error), privacy: .public)"
|
|
)
|
|
snapshotContainer = nil
|
|
}
|
|
Log.app.info(
|
|
"Zitare starting — auth status: \(String(describing: auth.status), privacy: .public)"
|
|
)
|
|
}
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
RootView()
|
|
.environment(auth)
|
|
.tint(ZitareTheme.primary)
|
|
.task {
|
|
await refreshSnapshot()
|
|
}
|
|
}
|
|
}
|
|
|
|
private func refreshSnapshot() async {
|
|
guard let container = snapshotContainer else { return }
|
|
let sync = SnapshotSync(container: container)
|
|
await sync.tryRefresh()
|
|
// Widget-Timeline neu erstellen lassen, sodass der nächste
|
|
// Render-Pass den frischen Snapshot sieht.
|
|
WidgetCenter.shared.reloadAllTimelines()
|
|
}
|
|
}
|