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:
co-authored by
Claude Opus 5
parent
ad7a405f32
commit
b28c5a0502
@@ -599,7 +599,8 @@ class CalendarStore {
|
||||
colorHex: ev.calendarColor)
|
||||
}
|
||||
}
|
||||
WidgetStore.writeCalendars(Array(calendarMap.values).sorted { $0.name < $1.name })
|
||||
let calendars = Array(calendarMap.values).sorted { $0.name < $1.name }
|
||||
WidgetStore.writeCalendars(calendars)
|
||||
|
||||
let visible = allCachedEvents
|
||||
.filter { ev in
|
||||
@@ -620,10 +621,14 @@ class CalendarStore {
|
||||
location: ev.location,
|
||||
calendarKey: Self.calendarKey(source: ev.source, calendarId: ev.calendarId))
|
||||
}
|
||||
WidgetStore.write(WidgetStore.makeSnapshot(events: Array(visible),
|
||||
coverageStart: from,
|
||||
coverageEnd: to))
|
||||
let snapshot = WidgetStore.makeSnapshot(events: Array(visible),
|
||||
coverageStart: from,
|
||||
coverageEnd: to)
|
||||
WidgetStore.write(snapshot)
|
||||
WidgetTimelineNotifier.reload()
|
||||
// The watch has its own container and cannot read the file we just
|
||||
// wrote, so it is handed the data explicitly.
|
||||
WatchSyncService.shared.push(snapshot: snapshot, calendars: calendars)
|
||||
}
|
||||
|
||||
// MARK: – Writable calendars
|
||||
|
||||
Reference in New Issue
Block a user