Convert to async/await.

This commit is contained in:
Brent Simmons committed 2025-11-07 09:46:39 -08:00
1 parent 74c14ab1db
commit d2c1afda6a
8 files changed
+55 -9

No files matched your search

@@ -637,7 +637,14 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
public func restoreFolder(_ folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
delegate.restoreFolder(for: self, folder: folder, completion: completion)
Task { @MainActor in
do {
try await delegate.restoreFolder(for: self, folder: folder)
completion(.success(()))
} catch {
completion(.failure(error))
}
}
}
func clearFeedMetadata(_ feed: Feed) {
@@ -43,7 +43,7 @@ protocol AccountDelegate {
@MainActor func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws
@MainActor func restoreFeed(for account: Account, feed: Feed, container: Container) async throws
func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void)
@MainActor func restoreFolder(for account: Account, folder: Folder) async throws
func markArticles(for account: Account, articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool, completion: @escaping (Result<Void, Error>) -> Void)
@@ -416,7 +416,15 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func restoreFolder(for account: Account, folder: Folder) async throws {
try await withCheckedThrowingContinuation { continuation in
restoreFolder(for: account, folder: folder) { result in
continuation.resume(with: result)
}
}
}
private func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
guard let name = folder.name else {
completion(.failure(LocalAccountDelegateError.invalidParameter))
return
@@ -489,7 +489,15 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func restoreFolder(for account: Account, folder: Folder) async throws {
try await withCheckedThrowingContinuation { continuation in
restoreFolder(for: account, folder: folder) { result in
continuation.resume(with: result)
}
}
}
private func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
let group = DispatchGroup()
@@ -541,7 +541,15 @@ final class FeedlyAccountDelegate: AccountDelegate {
}
}
func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func restoreFolder(for account: Account, folder: Folder) async throws {
try await withCheckedThrowingContinuation { continuation in
restoreFolder(for: account, folder: folder) { result in
continuation.resume(with: result)
}
}
}
private func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
let group = DispatchGroup()
for feed in folder.topLevelFeeds {
@@ -159,9 +159,8 @@ final class LocalAccountDelegate: AccountDelegate {
completion(.success(()))
}
func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func restoreFolder(for account: Account, folder: Folder) async throws {
account.addFolder(folder)
completion(.success(()))
}
func markArticles(for account: Account, articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool, completion: @escaping (Result<Void, Error>) -> Void) {
@@ -600,7 +600,15 @@ final class NewsBlurAccountDelegate: AccountDelegate {
}
}
func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> ()) {
@MainActor func restoreFolder(for account: Account, folder: Folder) async throws {
try await withCheckedThrowingContinuation { continuation in
restoreFolder(for: account, folder: folder) { result in
continuation.resume(with: result)
}
}
}
private func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> ()) {
guard let folderName = folder.name else {
completion(.failure(NewsBlurError.invalidParameter))
return
@@ -605,7 +605,15 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func restoreFolder(for account: Account, folder: Folder) async throws {
try await withCheckedThrowingContinuation { continuation in
restoreFolder(for: account, folder: folder) { result in
continuation.resume(with: result)
}
}
}
private func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void) {
let group = DispatchGroup()