Automatically remove Feed items if they should be filtered. Issue #1949

This commit is contained in:
Maurice Parker 2020-03-27 18:24:57 -05:00
parent a13f10441f
commit bd1c73c1d3
1 changed files with 9 additions and 15 deletions

View File

@ -61,7 +61,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
private var wasRootSplitViewControllerCollapsed = false
private let fetchAndMergeArticlesQueue = CoalescingQueue(name: "Fetch and Merge Articles", interval: 0.5)
private let rebuildBackingStoresWithMergeQueue = CoalescingQueue(name: "Rebuild The Backing Stores by Merging", interval: 1.0)
private let rebuildBackingStoresQueue = CoalescingQueue(name: "Rebuild The Backing Stores", interval: 1.0)
private var fetchSerialNumber = 0
private let fetchRequestQueue = FetchRequestQueue()
@ -441,12 +441,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
return
}
// If we are filtering reads, the new unread count is greater than 1, and the feed isn't shown then continue
guard let feed = note.object as? Feed, isReadFeedsFiltered, feed.unreadCount > 0, !shadowTableContains(feed) else {
return
}
rebuildBackingStoresWithMergeQueue.add(self, #selector(rebuildBackingStoresWithMerge))
rebuildBackingStoresQueue.add(self, #selector(rebuildBackingStoresWithDefaults))
}
@objc func statusesDidChange(_ note: Notification) {
@ -465,7 +460,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
@objc func batchUpdateDidPerform(_ notification: Notification) {
rebuildBackingStoresWithMerge()
rebuildBackingStores()
}
@objc func displayNameDidChange(_ note: Notification) {
@ -541,7 +536,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
@objc func downloadArticlesDidUpdateUnreadCounts(_ note: Notification) {
rebuildBackingStoresWithMerge()
rebuildBackingStores()
}
@objc func accountDidDownloadArticles(_ note: Notification) {
@ -568,7 +563,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
func suspend() {
fetchAndMergeArticlesQueue.performCallsImmediately()
rebuildBackingStoresWithMergeQueue.performCallsImmediately()
rebuildBackingStoresQueue.performCallsImmediately()
fetchRequestQueue.cancelAllRequests()
}
@ -1361,6 +1356,10 @@ private extension SceneCoordinator {
}
}
@objc func rebuildBackingStoresWithDefaults() {
rebuildBackingStores()
}
func rebuildBackingStores(initialLoad: Bool = false, updateExpandedNodes: (() -> Void)? = nil, completion: (() -> Void)? = nil) {
if !animatingChanges && !BatchUpdate.shared.isPerforming {
@ -1375,11 +1374,6 @@ private extension SceneCoordinator {
}
}
@objc func rebuildBackingStoresWithMerge() {
addShadowTableToFilterExceptions()
rebuildBackingStores()
}
func rebuildShadowTable() {
shadowTable = [[Node]]()