Convert to async/await.

This commit is contained in:
Brent Simmons committed 2025-11-06 21:10:04 -08:00
1 parent 27a2782413
commit 38aa43ca6e
8 files changed
+55 -9

No files matched your search

@@ -591,7 +591,14 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
public func moveFeed(_ feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
delegate.moveFeed(for: self, with: feed, from: from, to: to, completion: completion)
Task { @MainActor in
do {
try await delegate.moveFeed(for: self, with: feed, from: from, to: to)
completion(.success(()))
} catch {
completion(.failure(error))
}
}
}
public func renameFeed(_ feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
@@ -40,7 +40,7 @@ protocol AccountDelegate {
@MainActor func renameFeed(for account: Account, with feed: Feed, to name: String) async throws
func addFeed(for account: Account, with: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void)
func removeFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result<Void, Error>) -> Void)
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void)
@MainActor func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws
func restoreFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result<Void, Error>) -> Void)
func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void)
@@ -258,7 +258,15 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
}
func moveFeed(for account: Account, with feed: Feed, from fromContainer: Container, to toContainer: Container, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
try await withCheckedThrowingContinuation{ continuation in
moveFeed(for: account, with: feed, from: from, to: to) { result in
continuation.resume(with: result)
}
}
}
private func moveFeed(for account: Account, with feed: Feed, from fromContainer: Container, to toContainer: Container, completion: @escaping (Result<Void, Error>) -> Void) {
syncProgress.addToNumberOfTasksAndRemaining(1)
accountZone.moveFeed(feed, from: fromContainer, to: toContainer) { result in
self.syncProgress.completeTask()
@@ -402,7 +402,15 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
}
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
try await withCheckedThrowingContinuation{ continuation in
moveFeed(for: account, with: feed, from: from, to: to) { result in
continuation.resume(with: result)
}
}
}
private func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if from is Account {
addFeed(for: account, with: feed, to: to, completion: completion)
} else {
@@ -470,7 +470,15 @@ final class FeedlyAccountDelegate: AccountDelegate {
folder.removeFeed(feed)
}
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
try await withCheckedThrowingContinuation{ continuation in
moveFeed(for: account, with: feed, from: from, to: to) { result in
continuation.resume(with: result)
}
}
}
private func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
guard let from = from as? Folder, let to = to as? Folder else {
return DispatchQueue.main.async {
completion(.failure(FeedlyAccountDelegateError.addFeedChooseFolder))
@@ -129,10 +129,9 @@ final class LocalAccountDelegate: AccountDelegate {
completion(.success(()))
}
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
from.removeFeed(feed)
to.addFeed(feed)
completion(.success(()))
}
func addFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
@@ -535,7 +535,15 @@ final class NewsBlurAccountDelegate: AccountDelegate {
deleteFeed(for: account, with: feed, from: container, completion: completion)
}
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> ()) {
@MainActor func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
try await withCheckedThrowingContinuation{ continuation in
moveFeed(for: account, with: feed, from: from, to: to) { result in
continuation.resume(with: result)
}
}
}
private func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> ()) {
guard let feedID = feed.externalID else {
completion(.failure(NewsBlurError.invalidParameter))
return
@@ -507,7 +507,15 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
}
func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
@MainActor func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container) async throws {
try await withCheckedThrowingContinuation{ continuation in
moveFeed(for: account, with: feed, from: from, to: to) { result in
continuation.resume(with: result)
}
}
}
private func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if from is Account {
addFeed(for: account, with: feed, to: to, completion: completion)
} else {