mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-01 19:46:56 +01:00
Remove fetchUnreadArticlesAsync method.
This commit is contained in:
parent
4990a99ba8
commit
aab7ab7a80
@ -16,7 +16,6 @@ public protocol ArticleFetcher {
|
||||
@MainActor func fetchArticlesAsync(_ completion: @escaping ArticleSetResultBlock)
|
||||
|
||||
@MainActor func fetchUnreadArticles() async throws -> Set<Article>
|
||||
@MainActor func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock)
|
||||
}
|
||||
|
||||
extension Feed: ArticleFetcher {
|
||||
@ -49,22 +48,6 @@ extension Feed: ArticleFetcher {
|
||||
|
||||
return try await account.unreadArticles(feed: self)
|
||||
}
|
||||
|
||||
public func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
|
||||
guard let account = account else {
|
||||
assertionFailure("Expected feed.account, but got nil.")
|
||||
completion(.success(Set<Article>()))
|
||||
return
|
||||
}
|
||||
account.fetchArticlesAsync(.feed(self)) { articleSetResult in
|
||||
switch articleSetResult {
|
||||
case .success(let articles):
|
||||
completion(.success(articles.unreadArticles()))
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Folder: ArticleFetcher {
|
||||
@ -89,17 +72,6 @@ extension Folder: ArticleFetcher {
|
||||
|
||||
try await articles(unreadOnly: true)
|
||||
}
|
||||
|
||||
public func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
|
||||
|
||||
guard let account else {
|
||||
assertionFailure("Expected folder.account, but got nil.")
|
||||
completion(.success(Set<Article>()))
|
||||
return
|
||||
}
|
||||
|
||||
account.fetchArticlesAsync(.folder(self, true), completion)
|
||||
}
|
||||
}
|
||||
|
||||
private extension Folder {
|
||||
|
@ -103,11 +103,6 @@ extension SmartFeed: ArticleFetcher {
|
||||
|
||||
try await delegate.fetchUnreadArticles()
|
||||
}
|
||||
|
||||
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
|
||||
|
||||
delegate.fetchUnreadArticlesAsync(completion)
|
||||
}
|
||||
}
|
||||
|
||||
private extension SmartFeed {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user