Convert to async/await.

This commit is contained in:
Brent Simmons committed 2025-11-07 10:32:53 -08:00
1 parent 9ab34132ff
commit 98a625ceef
8 files changed
+55 -9

No files matched your search

@@ -628,7 +628,14 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
public func removeFolder(_ folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
delegate.removeFolder(for: self, with: folder, completion: completion)
Task { @MainActor in
do {
try await delegate.removeFolder(for: self, with: folder)
completion(.success(()))
} catch {
completion(.failure(error))
}
}
}
public func renameFolder(_ folder: Folder, to name: String) async throws {
@@ -34,7 +34,7 @@ protocol AccountDelegate {
@MainActor func createFolder(for account: Account, name: String) async throws -> Folder
@MainActor func renameFolder(for account: Account, with folder: Folder, to name: String) async throws
func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void)
@MainActor func removeFolder(for account: Account, with folder: Folder) async throws
@MainActor func createFeed(for account: Account, url: String, name: String?, container: Container, validateFeed: Bool) async throws -> Feed
@MainActor func renameFeed(for account: Account, with feed: Feed, to name: String) async throws
@@ -340,7 +340,15 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
}
func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func removeFolder(for account: Account, with folder: Folder) async throws {
try await withCheckedThrowingContinuation { continuation in
removeFolder(for: account, with: folder) { result in
continuation.resume(with: result)
}
}
}
private func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
syncProgress.addToNumberOfTasksAndRemaining(2)
accountZone.findFeedExternalIDs(for: folder) { result in
@@ -265,7 +265,15 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func removeFolder(for account: Account, with folder: Folder) async throws {
try await withCheckedThrowingContinuation { continuation in
removeFolder(for: account, with: folder) { result in
continuation.resume(with: result)
}
}
}
private func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
// Feedbin uses tags and if at least one feed isn't tagged, then the folder doesn't exist on their system
guard folder.hasAtLeastOneFeed() else {
@@ -331,7 +331,15 @@ final class FeedlyAccountDelegate: AccountDelegate {
folder.name = name
}
func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func removeFolder(for account: Account, with folder: Folder) async throws {
try await withCheckedThrowingContinuation { continuation in
removeFolder(for: account, with: folder) { result in
continuation.resume(with: result)
}
}
}
private func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
guard let id = folder.externalID else {
return DispatchQueue.main.async {
completion(.failure(FeedlyAccountDelegateError.unableToRemoveFolder(folder.nameForDisplay)))
@@ -128,9 +128,8 @@ final class LocalAccountDelegate: AccountDelegate {
folder.name = name
}
func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func removeFolder(for account: Account, with folder: Folder) async throws {
account.removeFolderFromTree(folder)
completion(.success(()))
}
@MainActor func restoreFolder(for account: Account, folder: Folder) async throws {
@@ -420,7 +420,15 @@ final class NewsBlurAccountDelegate: AccountDelegate {
folder.name = name
}
func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> ()) {
@MainActor func removeFolder(for account: Account, with folder: Folder) async throws {
try await withCheckedThrowingContinuation { continuation in
removeFolder(for: account, with: folder) { result in
continuation.resume(with: result)
}
}
}
private func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> ()) {
guard let folderToRemove = folder.name else {
completion(.failure(NewsBlurError.invalidParameter))
return
@@ -322,7 +322,15 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func removeFolder(for account: Account, with folder: Folder) async throws {
try await withCheckedThrowingContinuation { continuation in
removeFolder(for: account, with: folder) { result in
continuation.resume(with: result)
}
}
}
private func removeFolder(for account: Account, with folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
let group = DispatchGroup()