Send the trimmed snapshot to the watch over WatchConnectivity

App Groups are per-device, so the watch cannot read the file the phone writes
and has to be handed the data. Three delivery paths: application context for
the latest state, a complication push only when the next appointment actually
changed (the budget is small), and a reply to the watch asking directly.

Sign-out pushes an empty signed-out snapshot. Clearing our own container is not
enough — the watch holds its own copy and would keep rendering the previous
user's calendar.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Scarriffle
2026-09-11 16:40:45 +02:00
co-authored by Claude Opus 5
parent ad7a405f32
commit b28c5a0502
3 changed files with 169 additions and 4 deletions
+4
View File
@@ -8,6 +8,7 @@ struct CalendarrApp: App {
// Registration has to happen before the app finishes launching, which
// is why it is here and not in a .task modifier.
BackgroundRefresh.register()
WatchSyncService.shared.activate()
}
var body: some Scene {
@@ -114,6 +115,9 @@ class AppState {
// say "sign in to Calendarr" rather than "open Calendarr once".
WidgetStore.clear()
publishSession()
// The watch keeps its own copy of the snapshot, so clearing ours is not
// enough — it has to be told, or it keeps rendering this user's events.
WatchSyncService.shared.pushSignedOut()
}
func resetServer() {