Remove fetchUnreadArticlesAsync method.

This commit is contained in:
Brent Simmons
2024-03-24 22:56:09 -07:00
parent 4990a99ba8
commit aab7ab7a80
4 changed files with 12 additions and 50 deletions

View File

@@ -103,11 +103,6 @@ extension SmartFeed: ArticleFetcher {
try await delegate.fetchUnreadArticles()
}
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
delegate.fetchUnreadArticlesAsync(completion)
}
}
private extension SmartFeed {

View File

@@ -73,16 +73,11 @@ extension UnreadFeed: ArticleFetcher {
func fetchArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
fetchUnreadArticlesAsync(completion)
AccountManager.shared.fetchArticlesAsync(fetchType, completion)
}
func fetchUnreadArticles() async throws -> Set<Article> {
try await AccountManager.shared.fetchArticles(fetchType: fetchType)
}
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
AccountManager.shared.fetchArticlesAsync(fetchType, completion)
}
}

View File

@@ -62,7 +62,7 @@ final class FetchRequestOperation {
var fetchersReturned = 0
var fetchedArticles = Set<Article>()
func process(_ articles: Set<Article>) {
func process(_ articles: Set<Article>?) {
precondition(Thread.isMainThread)
guard !self.isCanceled else {
callCompletionIfNeeded()
@@ -71,7 +71,10 @@ final class FetchRequestOperation {
assert(!self.isFinished)
fetchedArticles.formUnion(articles)
if let articles {
fetchedArticles.formUnion(articles)
}
fetchersReturned += 1
if fetchersReturned == numberOfFetchers {
self.isFinished = true
@@ -80,19 +83,16 @@ final class FetchRequestOperation {
}
}
for fetcher in fetchers {
if (fetcher as? SidebarItem)?.readFiltered(readFilterEnabledTable: readFilterEnabledTable) ?? true {
fetcher.fetchUnreadArticlesAsync { articleSetResult in
let articles = (try? articleSetResult.get()) ?? Set<Article>()
Task { @MainActor in
for fetcher in fetchers {
if (fetcher as? SidebarItem)?.readFiltered(readFilterEnabledTable: readFilterEnabledTable) ?? true {
let articles = try? await fetcher.fetchUnreadArticles()
process(articles)
}
} else {
fetcher.fetchArticlesAsync { articleSetResult in
let articles = (try? articleSetResult.get()) ?? Set<Article>()
} else {
let articles = try? await fetcher.fetchArticles()
process(articles)
}
}
}
}
}