mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Make async version of fetchArticles.
This commit is contained in:
@@ -56,7 +56,7 @@ public enum FetchType {
|
||||
case unread(_: Int? = nil)
|
||||
case today(_: Int? = nil)
|
||||
case folder(Folder, Bool)
|
||||
case feed(Feed)
|
||||
case feed(Feed) // TODO: use feedID instead of Feed
|
||||
case articleIDs(Set<String>)
|
||||
case search(String)
|
||||
case searchWithArticleIDs(String, Set<String>)
|
||||
@@ -671,6 +671,20 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor public func fetchArticles(_ fetchType: FetchType) async throws -> Set<Article> {
|
||||
assert(Thread.isMainThread)
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
fetchArticlesAsync(fetchType) { articleSetResult in
|
||||
switch articleSetResult {
|
||||
case .success(let articles):
|
||||
continuation.resume(returning: articles)
|
||||
case .failure(let error):
|
||||
continuation.resume(throwing: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func fetchArticlesAsync(_ fetchType: FetchType, _ completion: @escaping ArticleSetResultBlock) {
|
||||
switch fetchType {
|
||||
case .starred(let limit):
|
||||
|
||||
Reference in New Issue
Block a user