mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 23:58:36 +01:00
Change to utilize ArticleFetchers instead of Feeds so that the single article fetcher stops getting filtered out. Issue #2416
This commit is contained in:
parent
feba4a7bc6
commit
c580877a86
@ -1129,19 +1129,19 @@ private extension TimelineViewController {
|
||||
|
||||
func fetchUnsortedArticlesSync(for representedObjects: [Any]) -> Set<Article> {
|
||||
cancelPendingAsyncFetches()
|
||||
let feeds = representedObjects.compactMap{ $0 as? Feed }
|
||||
if feeds.isEmpty {
|
||||
let fetchers = representedObjects.compactMap{ $0 as? ArticleFetcher }
|
||||
if fetchers.isEmpty {
|
||||
return Set<Article>()
|
||||
}
|
||||
|
||||
var fetchedArticles = Set<Article>()
|
||||
for feed in feeds {
|
||||
if feed.readFiltered(readFilterEnabledTable: readFilterEnabledTable) {
|
||||
if let articles = try? feed.fetchUnreadArticles() {
|
||||
for fetchers in fetchers {
|
||||
if (fetchers as? Feed)?.readFiltered(readFilterEnabledTable: readFilterEnabledTable) ?? true {
|
||||
if let articles = try? fetchers.fetchUnreadArticles() {
|
||||
fetchedArticles.formUnion(articles)
|
||||
}
|
||||
} else {
|
||||
if let articles = try? feed.fetchArticles() {
|
||||
if let articles = try? fetchers.fetchArticles() {
|
||||
fetchedArticles.formUnion(articles)
|
||||
}
|
||||
}
|
||||
@ -1154,8 +1154,8 @@ private extension TimelineViewController {
|
||||
// if it’s been superseded by a newer fetch, or the timeline was emptied, etc., it won’t get called.
|
||||
precondition(Thread.isMainThread)
|
||||
cancelPendingAsyncFetches()
|
||||
let feeds = representedObjects.compactMap { $0 as? Feed }
|
||||
let fetchOperation = FetchRequestOperation(id: fetchSerialNumber, readFilterEnabledTable: readFilterEnabledTable, feeds: feeds) { [weak self] (articles, operation) in
|
||||
let fetchers = representedObjects.compactMap { $0 as? ArticleFetcher }
|
||||
let fetchOperation = FetchRequestOperation(id: fetchSerialNumber, readFilterEnabledTable: readFilterEnabledTable, fetchers: fetchers) { [weak self] (articles, operation) in
|
||||
precondition(Thread.isMainThread)
|
||||
guard !operation.isCanceled, let strongSelf = self, operation.id == strongSelf.fetchSerialNumber else {
|
||||
return
|
||||
|
@ -23,13 +23,13 @@ final class FetchRequestOperation {
|
||||
let resultBlock: FetchRequestOperationResultBlock
|
||||
var isCanceled = false
|
||||
var isFinished = false
|
||||
private let feeds: [Feed]
|
||||
private let fetchers: [ArticleFetcher]
|
||||
|
||||
init(id: Int, readFilterEnabledTable: [FeedIdentifier: Bool], feeds: [Feed], resultBlock: @escaping FetchRequestOperationResultBlock) {
|
||||
init(id: Int, readFilterEnabledTable: [FeedIdentifier: Bool], fetchers: [ArticleFetcher], resultBlock: @escaping FetchRequestOperationResultBlock) {
|
||||
precondition(Thread.isMainThread)
|
||||
self.id = id
|
||||
self.readFilterEnabledTable = readFilterEnabledTable
|
||||
self.feeds = feeds
|
||||
self.fetchers = fetchers
|
||||
self.resultBlock = resultBlock
|
||||
}
|
||||
|
||||
@ -51,14 +51,14 @@ final class FetchRequestOperation {
|
||||
return
|
||||
}
|
||||
|
||||
if feeds.isEmpty {
|
||||
if fetchers.isEmpty {
|
||||
isFinished = true
|
||||
resultBlock(Set<Article>(), self)
|
||||
callCompletionIfNeeded()
|
||||
return
|
||||
}
|
||||
|
||||
let numberOfFetchers = feeds.count
|
||||
let numberOfFetchers = fetchers.count
|
||||
var fetchersReturned = 0
|
||||
var fetchedArticles = Set<Article>()
|
||||
|
||||
@ -80,19 +80,19 @@ final class FetchRequestOperation {
|
||||
}
|
||||
}
|
||||
|
||||
for feed in feeds {
|
||||
if feed.readFiltered(readFilterEnabledTable: readFilterEnabledTable) {
|
||||
feed.fetchUnreadArticlesAsync { articleSetResult in
|
||||
let articles = (try? articleSetResult.get()) ?? Set<Article>()
|
||||
process(articles)
|
||||
}
|
||||
}
|
||||
else {
|
||||
feed.fetchArticlesAsync { articleSetResult in
|
||||
for fetcher in fetchers {
|
||||
if (fetcher as? Feed)?.readFiltered(readFilterEnabledTable: readFilterEnabledTable) ?? true {
|
||||
fetcher.fetchUnreadArticlesAsync { articleSetResult in
|
||||
let articles = (try? articleSetResult.get()) ?? Set<Article>()
|
||||
process(articles)
|
||||
}
|
||||
} else {
|
||||
fetcher.fetchArticlesAsync { articleSetResult in
|
||||
let articles = (try? articleSetResult.get()) ?? Set<Article>()
|
||||
process(articles)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1906,8 +1906,8 @@ private extension SceneCoordinator {
|
||||
precondition(Thread.isMainThread)
|
||||
cancelPendingAsyncFetches()
|
||||
|
||||
let feeds = representedObjects.compactMap { $0 as? Feed }
|
||||
let fetchOperation = FetchRequestOperation(id: fetchSerialNumber, readFilterEnabledTable: readFilterEnabledTable, feeds: feeds) { [weak self] (articles, operation) in
|
||||
let fetchers = representedObjects.compactMap { $0 as? ArticleFetcher }
|
||||
let fetchOperation = FetchRequestOperation(id: fetchSerialNumber, readFilterEnabledTable: readFilterEnabledTable, fetchers: fetchers) { [weak self] (articles, operation) in
|
||||
precondition(Thread.isMainThread)
|
||||
guard !operation.isCanceled, let strongSelf = self, operation.id == strongSelf.fetchSerialNumber else {
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user