commit e868c6aaee4724a9e52849984da468e652d0a318
parent a150c6e718ed13657b626dc8734dc00d7543e291
Author: Michael Camilleri <[email protected]>
Date: Sun, 26 Apr 2026 21:44:49 +0900
Improve display of share sheet
Diffstat:
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/Crossmate/Sync/ShareController.swift b/Crossmate/Sync/ShareController.swift
@@ -46,11 +46,21 @@ final class ShareController {
)
}
- // Ensure the zone exists in CloudKit before creating the share.
- try await syncEngine.pushChanges()
-
let zoneName = entity.ckZoneName ?? "game-\(gameID.uuidString)"
let zoneID = CKRecordZone.ID(zoneName: zoneName, ownerName: CKCurrentUserDefaultName)
+
+ // Create the zone directly rather than going through CKSyncEngine.sendChanges(),
+ // which can block on post-reset state (stale tokens, in-flight operations).
+ // Zone creation is idempotent so this is safe even if the engine already created it.
+ try await withCheckedThrowingContinuation { (cont: CheckedContinuation<Void, Error>) in
+ let op = CKModifyRecordZonesOperation(
+ recordZonesToSave: [CKRecordZone(zoneID: zoneID)],
+ recordZoneIDsToDelete: nil
+ )
+ op.qualityOfService = .userInitiated
+ op.modifyRecordZonesResultBlock = { result in cont.resume(with: result) }
+ self.container.privateCloudDatabase.add(op)
+ }
let share = CKShare(recordZoneID: zoneID)
share.publicPermission = .none