Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Make callback-based functions in CloudKitZone public again. Makes ado…
Browse files Browse the repository at this point in the history
…pting async/await everywhere less urgent.
  • Loading branch information
brentsimmons committed Feb 21, 2024
1 parent fb18a16 commit 9fa9d68
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions Sources/RSCore/CloudKit/CloudKitZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public extension CloudKitZone {
}
}

private func createZoneRecord(completion: @escaping (Result<Void, Error>) -> Void) {
func createZoneRecord(completion: @escaping (Result<Void, Error>) -> Void) {
guard let database = database else {
completion(.failure(CloudKitZoneError.unknown))
return
Expand Down Expand Up @@ -199,7 +199,7 @@ public extension CloudKitZone {
}
}

private func query(_ ckQuery: CKQuery, desiredKeys: [String]? = nil, completion: @escaping (Result<[CKRecord], Error>) -> Void) {
func query(_ ckQuery: CKQuery, desiredKeys: [String]? = nil, completion: @escaping (Result<[CKRecord], Error>) -> Void) {
var records = [CKRecord]()

let op = CKQueryOperation(query: ckQuery)
Expand Down Expand Up @@ -272,7 +272,7 @@ public extension CloudKitZone {
}
}

private func query(cursor: CKQueryOperation.Cursor, desiredKeys: [String]? = nil, carriedRecords: [CKRecord], completion: @escaping (Result<[CKRecord], Error>) -> Void) {
func query(cursor: CKQueryOperation.Cursor, desiredKeys: [String]? = nil, carriedRecords: [CKRecord], completion: @escaping (Result<[CKRecord], Error>) -> Void) {
var records = carriedRecords

let op = CKQueryOperation(cursor: cursor)
Expand Down Expand Up @@ -345,7 +345,7 @@ public extension CloudKitZone {
}
}

private func fetch(externalID: String?, completion: @escaping (Result<CKRecord, Error>) -> Void) {
func fetch(externalID: String?, completion: @escaping (Result<CKRecord, Error>) -> Void) {
guard let externalID = externalID else {
completion(.failure(CloudKitZoneError.corruptAccount))
return
Expand Down Expand Up @@ -410,7 +410,7 @@ public extension CloudKitZone {
}
}

private func save(_ record: CKRecord, completion: @escaping (Result<Void, Error>) -> Void) {
func save(_ record: CKRecord, completion: @escaping (Result<Void, Error>) -> Void) {
modify(recordsToSave: [record], recordIDsToDelete: [], completion: completion)
}

Expand All @@ -428,7 +428,7 @@ public extension CloudKitZone {
}
}

private func save(_ records: [CKRecord], completion: @escaping (Result<Void, Error>) -> Void) {
func save(_ records: [CKRecord], completion: @escaping (Result<Void, Error>) -> Void) {
modify(recordsToSave: records, recordIDsToDelete: [], completion: completion)
}

Expand All @@ -446,7 +446,7 @@ public extension CloudKitZone {
}
}

private func saveIfNew(_ records: [CKRecord], completion: @escaping (Result<Void, Error>) -> Void) {
func saveIfNew(_ records: [CKRecord], completion: @escaping (Result<Void, Error>) -> Void) {
let op = CKModifyRecordsOperation(recordsToSave: records, recordIDsToDelete: [CKRecord.ID]())
op.savePolicy = .ifServerRecordUnchanged
op.isAtomic = false
Expand Down Expand Up @@ -531,7 +531,7 @@ public extension CloudKitZone {
}
}

private func save(_ subscription: CKSubscription, completion: @escaping (Result<CKSubscription, Error>) -> Void) {
func save(_ subscription: CKSubscription, completion: @escaping (Result<CKSubscription, Error>) -> Void) {
database?.save(subscription) { [weak self] savedSubscription, error in
guard let self = self else {
completion(.failure(CloudKitZoneError.unknown))
Expand Down Expand Up @@ -581,7 +581,7 @@ public extension CloudKitZone {
}
}

private func delete(ckQuery: CKQuery, completion: @escaping (Result<Void, Error>) -> Void) {
func delete(ckQuery: CKQuery, completion: @escaping (Result<Void, Error>) -> Void) {

var records = [CKRecord]()

Expand Down Expand Up @@ -632,7 +632,7 @@ public extension CloudKitZone {
}
}

private func delete(cursor: CKQueryOperation.Cursor, carriedRecords: [CKRecord], completion: @escaping (Result<Void, Error>) -> Void) {
func delete(cursor: CKQueryOperation.Cursor, carriedRecords: [CKRecord], completion: @escaping (Result<Void, Error>) -> Void) {

var records = [CKRecord]()

Expand Down Expand Up @@ -676,7 +676,7 @@ public extension CloudKitZone {
}
}

private func delete(recordID: CKRecord.ID, completion: @escaping (Result<Void, Error>) -> Void) {
func delete(recordID: CKRecord.ID, completion: @escaping (Result<Void, Error>) -> Void) {
modify(recordsToSave: [], recordIDsToDelete: [recordID], completion: completion)
}

Expand All @@ -694,7 +694,7 @@ public extension CloudKitZone {
}
}

private func delete(recordIDs: [CKRecord.ID], completion: @escaping (Result<Void, Error>) -> Void) {
func delete(recordIDs: [CKRecord.ID], completion: @escaping (Result<Void, Error>) -> Void) {
modify(recordsToSave: [], recordIDsToDelete: recordIDs, completion: completion)
}

Expand All @@ -712,7 +712,7 @@ public extension CloudKitZone {
}
}

private func delete(externalID: String?, completion: @escaping (Result<Void, Error>) -> Void) {
func delete(externalID: String?, completion: @escaping (Result<Void, Error>) -> Void) {
guard let externalID = externalID else {
completion(.failure(CloudKitZoneError.corruptAccount))
return
Expand All @@ -736,7 +736,7 @@ public extension CloudKitZone {
}
}

private func delete(subscriptionID: String, completion: @escaping (Result<Void, Error>) -> Void) {
func delete(subscriptionID: String, completion: @escaping (Result<Void, Error>) -> Void) {
database?.delete(withSubscriptionID: subscriptionID) { [weak self] _, error in
guard let self = self else {
completion(.failure(CloudKitZoneError.unknown))
Expand Down Expand Up @@ -776,7 +776,7 @@ public extension CloudKitZone {
}
}

private func modify(recordsToSave: [CKRecord], recordIDsToDelete: [CKRecord.ID], completion: @escaping (Result<Void, Error>) -> Void) {
func modify(recordsToSave: [CKRecord], recordIDsToDelete: [CKRecord.ID], completion: @escaping (Result<Void, Error>) -> Void) {
guard !(recordsToSave.isEmpty && recordIDsToDelete.isEmpty) else {
DispatchQueue.main.async {
completion(.success(()))
Expand Down Expand Up @@ -899,7 +899,7 @@ public extension CloudKitZone {
}
}

private func fetchChangesInZone(incremental: Bool = true, completion: @escaping (Result<Void, Error>) -> Void) {
func fetchChangesInZone(incremental: Bool = true, completion: @escaping (Result<Void, Error>) -> Void) {

var updatedRecords = [CKRecord]()
var deletedRecordKeys = [CloudKitRecordKey]()
Expand Down

0 comments on commit 9fa9d68

Please sign in to comment.