mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-03 12:27:32 +01:00
Convert sendArticleStatusAll to async/await.
This commit is contained in:
parent
028df3a8f8
commit
455f60a224
@ -436,6 +436,20 @@ public enum FetchType {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func syncArticleStatus(completion: ((Result<Void, Error>) -> Void)? = nil) {
|
||||
delegate.syncArticleStatus(for: self, completion: completion)
|
||||
}
|
||||
|
@ -274,18 +274,15 @@ import Secrets
|
||||
|
||||
}
|
||||
|
||||
public func sendArticleStatusAll(completion: (() -> Void)? = nil) {
|
||||
let group = DispatchGroup()
|
||||
|
||||
activeAccounts.forEach {
|
||||
group.enter()
|
||||
$0.sendArticleStatus() { _ in
|
||||
group.leave()
|
||||
}
|
||||
}
|
||||
public func sendArticleStatusAll() async {
|
||||
|
||||
group.notify(queue: DispatchQueue.global(qos: .background)) {
|
||||
completion?()
|
||||
await withTaskGroup(of: Void.self) { taskGroup in
|
||||
|
||||
for account in activeAccounts {
|
||||
taskGroup.addTask {
|
||||
try? await account.sendArticleStatus()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,8 @@ import Sparkle
|
||||
|
||||
ArticleThemeDownloader.cleanUp()
|
||||
|
||||
accountManager.sendArticleStatusAll() {
|
||||
Task { @MainActor in
|
||||
await accountManager.sendArticleStatusAll()
|
||||
self.isShutDownSyncDone = true
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user