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

View File

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