feat(sync): add pagination, cancellation, and network restoration
- CloudKit pagination: fetchAllRecords() handles >400 record batches with cursor-based pagination (400 records per page) - Cancellation support: SyncCancellationToken protocol enables graceful sync termination when background tasks expire - Per-entity progress: SyncState now tracks timestamps per entity type so interrupted syncs resume where they left off - NetworkMonitor: NWPathMonitor integration triggers sync on network restoration with 2.5s debounce to handle WiFi↔cellular flapping - wasCancelled flag in SyncResult distinguishes partial from full syncs This addresses critical data sync issues: - CloudKit queries were limited to ~400 records but bundled data has ~5000 games - Background tasks could be killed mid-sync without saving progress - App had no awareness of network state changes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,15 @@ final class SyncState {
|
||||
var gameChangeToken: Data?
|
||||
var leagueChangeToken: Data?
|
||||
|
||||
// Per-entity sync timestamps for partial progress
|
||||
var lastStadiumSync: Date?
|
||||
var lastTeamSync: Date?
|
||||
var lastGameSync: Date?
|
||||
var lastLeagueStructureSync: Date?
|
||||
var lastTeamAliasSync: Date?
|
||||
var lastStadiumAliasSync: Date?
|
||||
var lastSportSync: Date?
|
||||
|
||||
init() {}
|
||||
|
||||
static func current(in context: ModelContext) -> SyncState {
|
||||
|
||||
Reference in New Issue
Block a user