diff --git a/Account/Sources/Account/Account.swift b/Account/Sources/Account/Account.swift index 857c7e650..6e9bd4107 100644 --- a/Account/Sources/Account/Account.swift +++ b/Account/Sources/Account/Account.swift @@ -426,29 +426,9 @@ public enum FetchType { try await delegate.refreshAll(for: self) } - public func sendArticleStatus(completion: ((Result) -> Void)? = nil) { - delegate.sendArticleStatus(for: self) { result in - switch result { - case .success: - completion?(.success(())) - case .failure(let error): - completion?(.failure(error)) - } - } - } - public func sendArticleStatus() async throws { - try await withCheckedThrowingContinuation { continuation in - self.sendArticleStatus { result in - switch result { - case .success: - continuation.resume() - case .failure(let error): - continuation.resume(throwing: error) - } - } - } + try await delegate.sendArticleStatus(for: self) } public func syncArticleStatus() async throws { diff --git a/Account/Sources/Account/AccountDelegate.swift b/Account/Sources/Account/AccountDelegate.swift index 211348eae..849b7c217 100644 --- a/Account/Sources/Account/AccountDelegate.swift +++ b/Account/Sources/Account/AccountDelegate.swift @@ -27,7 +27,7 @@ import Secrets func refreshAll(for account: Account) async throws func syncArticleStatus(for account: Account) async throws - func sendArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) + func sendArticleStatus(for account: Account) async throws func refreshArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) func importOPML(for account:Account, opmlFile: URL, completion: @escaping (Result) -> Void) diff --git a/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift b/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift index a1247a9f5..538643919 100644 --- a/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift +++ b/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift @@ -124,7 +124,21 @@ enum CloudKitAccountDelegateError: LocalizedError { } } - func sendArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) { + func sendArticleStatus(for account: Account) async throws { + + try await withCheckedThrowingContinuation { continuation in + self.sendArticleStatus(for: account) { result in + switch result { + case .success: + continuation.resume() + case .failure(let error): + continuation.resume(throwing: error) + } + } + } + } + + private func sendArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) { sendArticleStatus(for: account, showProgress: false, completion: completion) } diff --git a/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift b/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift index 3782e7102..c3fff7168 100644 --- a/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift @@ -134,7 +134,22 @@ final class FeedbinAccountDelegate: AccountDelegate { } } - func sendArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) { + public func sendArticleStatus(for account: Account) async throws { + + try await withCheckedThrowingContinuation { continuation in + + self.sendArticleStatus(for: account) { result in + switch result { + case .success: + continuation.resume() + case .failure(let error): + continuation.resume(throwing: error) + } + } + } + } + + private func sendArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) { os_log(.debug, log: log, "Sending article statuses...") diff --git a/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift b/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift index 066711a1f..3ce26ed42 100644 --- a/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift +++ b/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift @@ -180,7 +180,22 @@ final class FeedlyAccountDelegate: AccountDelegate { } } - @MainActor func sendArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) { + public func sendArticleStatus(for account: Account) async throws { + + try await withCheckedThrowingContinuation { continuation in + + self.sendArticleStatus(for: account) { result in + switch result { + case .success: + continuation.resume() + case .failure(let error): + continuation.resume(throwing: error) + } + } + } + } + + @MainActor private func sendArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) { // Ensure remote articles have the same status as they do locally. let send = FeedlySendArticleStatusesOperation(database: database, service: caller, log: log) send.completionBlock = { operation in diff --git a/Account/Sources/Account/LocalAccount/LocalAccountDelegate.swift b/Account/Sources/Account/LocalAccount/LocalAccountDelegate.swift index 930e8a6f8..25f63ef75 100644 --- a/Account/Sources/Account/LocalAccount/LocalAccountDelegate.swift +++ b/Account/Sources/Account/LocalAccount/LocalAccountDelegate.swift @@ -62,8 +62,7 @@ final class LocalAccountDelegate: AccountDelegate { func syncArticleStatus(for account: Account) async throws { } - func sendArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) { - completion(.success(())) + func sendArticleStatus(for account: Account) async throws { } func refreshArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) { diff --git a/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift b/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift index 9e2ddce22..ee327efa6 100644 --- a/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift +++ b/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift @@ -149,7 +149,22 @@ final class NewsBlurAccountDelegate: AccountDelegate { } } - func sendArticleStatus(for account: Account, completion: @escaping (Result) -> ()) { + public func sendArticleStatus(for account: Account) async throws { + + try await withCheckedThrowingContinuation { continuation in + + self.sendArticleStatus(for: account) { result in + switch result { + case .success: + continuation.resume() + case .failure(let error): + continuation.resume(throwing: error) + } + } + } + } + + private func sendArticleStatus(for account: Account, completion: @escaping (Result) -> ()) { os_log(.debug, log: log, "Sending story statuses...") Task { @MainActor in diff --git a/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift index a49798d0c..e3fdc85b6 100644 --- a/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift +++ b/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift @@ -213,7 +213,21 @@ final class ReaderAPIAccountDelegate: AccountDelegate { } } - func sendArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) { + public func sendArticleStatus(for account: Account) async throws { + + try await withCheckedThrowingContinuation { continuation in + self.sendArticleStatus(for: account) { result in + switch result { + case .success: + continuation.resume() + case .failure(let error): + continuation.resume(throwing: error) + } + } + } + } + + private func sendArticleStatus(for account: Account, completion: @escaping ((Result) -> Void)) { os_log(.debug, log: log, "Sending article statuses...")