diff --git a/Modules/Account/Sources/Account/Account.swift b/Modules/Account/Sources/Account/Account.swift index 5a75ee1fb..16c3e334b 100644 --- a/Modules/Account/Sources/Account/Account.swift +++ b/Modules/Account/Sources/Account/Account.swift @@ -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) case search(String) case searchWithArticleIDs(String, Set) @@ -671,6 +671,20 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, } } + @MainActor public func fetchArticles(_ fetchType: FetchType) async throws -> Set
{ + 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):