crossmate

A collaborative crossword app for iOS
Log | Files | Refs | LICENSE

commit 5b91ff697d378262d83bee39121e8b08a468a9e0
parent df107211e64fbd73de2375f783c34e85aaaf35cc
Author: Michael Camilleri <[email protected]>
Date:   Sun,  3 May 2026 01:42:25 +0900

Fix leaving of shared games

Diffstat:
MCrossmate/Sync/ShareController.swift | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/Crossmate/Sync/ShareController.swift b/Crossmate/Sync/ShareController.swift @@ -193,9 +193,16 @@ final class ShareController { let zoneName = entity.ckZoneName ?? "game-\(gameID.uuidString)" let ownerName = entity.ckZoneOwnerName ?? CKCurrentUserDefaultName let zoneID = CKRecordZone.ID(zoneName: zoneName, ownerName: ownerName) + let shareID = CKRecord.ID(recordName: Self.zoneWideShareRecordName, zoneID: zoneID) - // Deleting the zone from the shared database removes our participation. - try await container.sharedCloudDatabase.deleteRecordZone(withID: zoneID) + // A participant leaves a zone-wide share by deleting the CKShare record + // from the shared database; deleting the zone itself is rejected with + // "Zone delete not allowed". + do { + try await container.sharedCloudDatabase.deleteRecord(withID: shareID) + } catch let error as CKError where error.code == .unknownItem || error.code == .zoneNotFound { + // Already gone — proceed to clean up local state. + } ctx.delete(entity) try ctx.save()