Convert to async/await.

This commit is contained in:
Brent Simmons committed 2025-11-08 21:17:41 -08:00
1 parent a6473ea625
commit 791a33bc55
4 files changed
+434 -524

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -333,6 +333,88 @@ final class CloudKitAccountZone: CloudKitZone {
delete(externalID: folder.externalID, completion: completion)
}
// MARK: - Async Wrappers
func createFeed(url: String, name: String?, editedName: String?, homePageURL: String?, container: Container) async throws -> String {
try await withCheckedThrowingContinuation { continuation in
createFeed(url: url, name: name, editedName: editedName, homePageURL: homePageURL, container: container) { result in
continuation.resume(with: result)
}
}
}
func renameFeed(_ feed: Feed, editedName: String?) async throws {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
renameFeed(feed, editedName: editedName) { result in
continuation.resume(with: result)
}
}
}
func removeFeed(_ feed: Feed, from: Container) async throws -> Bool {
try await withCheckedThrowingContinuation { continuation in
removeFeed(feed, from: from) { result in
continuation.resume(with: result)
}
}
}
func moveFeed(_ feed: Feed, from: Container, to: Container) async throws {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
moveFeed(feed, from: from, to: to) { result in
continuation.resume(with: result)
}
}
}
func addFeed(_ feed: Feed, to: Container) async throws {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
addFeed(feed, to: to) { result in
continuation.resume(with: result)
}
}
}
func findFeedExternalIDs(for folder: Folder) async throws -> [String] {
try await withCheckedThrowingContinuation { continuation in
findFeedExternalIDs(for: folder) { result in
continuation.resume(with: result)
}
}
}
func findOrCreateAccount() async throws -> String {
try await withCheckedThrowingContinuation { continuation in
findOrCreateAccount { result in
continuation.resume(with: result)
}
}
}
func createFolder(name: String) async throws -> String {
try await withCheckedThrowingContinuation { continuation in
createFolder(name: name) { result in
continuation.resume(with: result)
}
}
}
func renameFolder(_ folder: Folder, to name: String) async throws {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
renameFolder(folder, to: name) { result in
continuation.resume(with: result)
}
}
}
func removeFolder(_ folder: Folder) async throws {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
removeFolder(folder) { result in
continuation.resume(with: result)
}
}
}
}
private extension CloudKitAccountZone {
@@ -159,6 +159,40 @@ final class CloudKitArticlesZone: CloudKitZone {
}
// MARK: - Async Wrappers
func refreshArticles() async throws {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
refreshArticles { result in
continuation.resume(with: result)
}
}
}
func saveNewArticles(_ articles: Set<Article>) async throws {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
saveNewArticles(articles) { result in
continuation.resume(with: result)
}
}
}
func deleteArticles(_ feedExternalID: String) async throws {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
deleteArticles(feedExternalID) { result in
continuation.resume(with: result)
}
}
}
func modifyArticles(_ statusUpdates: [CloudKitArticleStatusUpdate]) async throws {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
modifyArticles(statusUpdates) { result in
continuation.resume(with: result)
}
}
}
}
private extension CloudKitArticlesZone {
@@ -208,7 +208,7 @@ final class ReaderAPICaller {
let newTagName = "user/-/label/\(encodedNewName)"
let postData = "T=\(token)&s=\(oldTagName)&dest=\(newTagName)".data(using: String.Encoding.utf8)
try await transport.send(request: request, method: HTTPMethod.post, payload: postData!)
_ = try await transport.send(request: request, method: HTTPMethod.post, payload: postData!)
}
public func deleteTag(folderExternalID: String) async throws {
@@ -226,7 +226,7 @@ final class ReaderAPICaller {
let postData = "T=\(token)&s=\(folderExternalID)".data(using: String.Encoding.utf8)
try await self.transport.send(request: request, method: HTTPMethod.post, payload: postData!)
_ = try await self.transport.send(request: request, method: HTTPMethod.post, payload: postData!)
}
public func retrieveSubscriptions() async throws -> [ReaderAPISubscription]? {
@@ -314,7 +314,7 @@ final class ReaderAPICaller {
let postData = "T=\(token)&s=\(subscriptionID)&ac=unsubscribe".data(using: String.Encoding.utf8)
try await self.transport.send(request: request, method: HTTPMethod.post, payload: postData!)
_ = try await self.transport.send(request: request, method: HTTPMethod.post, payload: postData!)
}
public func createTagging(subscriptionID: String, tagName: String) async throws {
@@ -360,7 +360,7 @@ final class ReaderAPICaller {
}
let postData = postString.data(using: String.Encoding.utf8)
try await transport.send(request: request, method: HTTPMethod.post, payload: postData!)
_ = try await transport.send(request: request, method: HTTPMethod.post, payload: postData!)
}
public func retrieveEntries(articleIDs: [String]) async throws -> [ReaderAPIEntry]? {
@@ -565,6 +565,6 @@ private extension ReaderAPICaller {
let postData = "T=\(token)&\(idsToFetch)&\(actionIndicator)=\(state.rawValue)".data(using: String.Encoding.utf8)
try await transport.send(request: request, method: HTTPMethod.post, payload: postData!)
_ = try await transport.send(request: request, method: HTTPMethod.post, payload: postData!)
}
}