mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Continue converting ArticlesDatabase to async/await.
This commit is contained in:
@@ -1239,7 +1239,19 @@ private extension Account {
|
||||
}
|
||||
|
||||
func fetchArticlesMatchingWithArticleIDsAsync(_ searchString: String, _ articleIDs: Set<String>, _ completion: @escaping ArticleSetResultBlock) {
|
||||
database.fetchArticlesMatchingWithArticleIDsAsync(searchString, articleIDs, completion)
|
||||
|
||||
Task { @MainActor in
|
||||
do {
|
||||
let articles = try await database.articlesForSearchStringInArticleIDs(searchString, articleIDs)
|
||||
Task { @MainActor in
|
||||
completion(.success(articles))
|
||||
}
|
||||
} catch {
|
||||
Task { @MainActor in
|
||||
completion(.failure(error as! DatabaseError))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func fetchArticles(articleIDs: Set<String>) throws -> Set<Article> {
|
||||
|
||||
@@ -161,13 +161,13 @@ public typealias ArticleStatusesResultBlock = (ArticleStatusesResult) -> Void
|
||||
}
|
||||
|
||||
public func articlesForSearchStringInFeeds(_ searchString: String, _ feedIDs: Set<String>) async throws -> Set<Article> {
|
||||
try await articlesTable.articleForSearchStringInFeeds(searchString, feedIDs)
|
||||
try await articlesTable.articlesForSearchStringInFeeds(searchString, feedIDs)
|
||||
}
|
||||
|
||||
public func fetchArticlesMatchingWithArticleIDsAsync(_ searchString: String, _ articleIDs: Set<String>, _ completion: @escaping ArticleSetResultBlock) {
|
||||
articlesTable.fetchArticlesMatchingWithArticleIDsAsync(searchString, articleIDs, completion)
|
||||
public func articlesForSearchStringInArticleIDs(_ searchString: String, _ articleIDs: Set<String>) async throws -> Set<Article> {
|
||||
try await articlesTable.articlesForSearchStringInArticleIDs(searchString, articleIDs)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Unread Counts
|
||||
|
||||
/// Fetch all non-zero unread counts.
|
||||
|
||||
@@ -149,12 +149,12 @@ final class ArticlesTable: DatabaseTable {
|
||||
return articles
|
||||
}
|
||||
|
||||
func articleForSearchStringInFeeds(_ searchString: String, _ feedIDs: Set<String>) async throws -> Set<Article> {
|
||||
func articlesForSearchStringInFeeds(_ searchString: String, _ feedIDs: Set<String>) async throws -> Set<Article> {
|
||||
try await articlesWithFetchMethod { self.fetchArticlesMatching(searchString, feedIDs, $0) }
|
||||
}
|
||||
|
||||
func fetchArticlesMatchingWithArticleIDsAsync(_ searchString: String, _ articleIDs: Set<String>, _ completion: @escaping ArticleSetResultBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticlesMatchingWithArticleIDs(searchString, articleIDs, $0) }, completion)
|
||||
func articlesForSearchStringInArticleIDs(_ searchString: String, _ articleIDs: Set<String>) async throws -> Set<Article> {
|
||||
try await articlesWithFetchMethod { self.fetchArticlesMatchingWithArticleIDs(searchString, articleIDs, $0) }
|
||||
}
|
||||
|
||||
// MARK: - Fetching Articles for Indexer
|
||||
|
||||
Reference in New Issue
Block a user