Changed so that Feeds and Timeline clear read items if necessary on manual refresh commands. Issues #1834, #1856, and #1845

This commit is contained in:
Maurice Parker 2020-03-11 14:47:00 -06:00
parent 326322ead6
commit 9007ed4b06
6 changed files with 25 additions and 12 deletions

View File

@ -134,6 +134,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
} }
// MARK: - API // MARK: - API
func manualRefresh(errorHandler: @escaping (Error) -> ()) {
UIApplication.shared.connectedScenes.compactMap( { $0.delegate as? SceneDelegate } ).forEach {
$0.refreshInterface()
}
AccountManager.shared.refreshAll(errorHandler: errorHandler)
}
func resumeDatabaseProcessingIfNecessary() { func resumeDatabaseProcessingIfNecessary() {
if AccountManager.shared.isSuspended { if AccountManager.shared.isSuspended {
AccountManager.shared.resumeAll() AccountManager.shared.resumeAll()

View File

@ -426,11 +426,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
// This is a hack to make sure that an error dialog doesn't interfere with dismissing the refreshControl. // This is a hack to make sure that an error dialog doesn't interfere with dismissing the refreshControl.
// If the error dialog appears too closely to the call to endRefreshing, then the refreshControl never disappears. // If the error dialog appears too closely to the call to endRefreshing, then the refreshControl never disappears.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
AccountManager.shared.refreshAll(errorHandler: ErrorHandler.present(self)) { appDelegate.manualRefresh(errorHandler: ErrorHandler.present(self))
if AppDefaults.refreshClearsReadArticles {
self.coordinator.refreshTimeline(resetScroll: false)
}
}
} }
} }

View File

@ -137,11 +137,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
// This is a hack to make sure that an error dialog doesn't interfere with dismissing the refreshControl. // This is a hack to make sure that an error dialog doesn't interfere with dismissing the refreshControl.
// If the error dialog appears too closely to the call to endRefreshing, then the refreshControl never disappears. // If the error dialog appears too closely to the call to endRefreshing, then the refreshControl never disappears.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
AccountManager.shared.refreshAll(errorHandler: ErrorHandler.present(self)) { appDelegate.manualRefresh(errorHandler: ErrorHandler.present(self))
if AppDefaults.refreshClearsReadArticles {
self.coordinator.refreshTimeline(resetScroll: false)
}
}
} }
} }

View File

@ -91,7 +91,7 @@ class RootSplitViewController: UISplitViewController {
} }
@objc func refresh(_ sender: Any?) { @objc func refresh(_ sender: Any?) {
AccountManager.shared.refreshAll(errorHandler: ErrorHandler.present(self)) appDelegate.manualRefresh(errorHandler: ErrorHandler.present(self))
} }
@objc func goToToday(_ sender: Any?) { @objc func goToToday(_ sender: Any?) {

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: 0.5) private let rebuildBackingStoresWithMergeQueue = CoalescingQueue(name: "Rebuild The Backing Stores by Merging", interval: 1.0)
private var fetchSerialNumber = 0 private var fetchSerialNumber = 0
private let fetchRequestQueue = FetchRequestQueue() private let fetchRequestQueue = FetchRequestQueue()
@ -572,6 +572,15 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
fetchRequestQueue.cancelAllRequests() fetchRequestQueue.cancelAllRequests()
} }
func refreshInterface() {
if isReadFeedsFiltered {
rebuildBackingStores()
}
if isReadArticlesFiltered && AppDefaults.refreshClearsReadArticles {
refreshTimeline(resetScroll: false)
}
}
func shadowNodesFor(section: Int) -> [Node] { func shadowNodesFor(section: Int) -> [Node] {
return shadowTable[section] return shadowTable[section]
} }

View File

@ -81,6 +81,10 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
coordinator.suspend() coordinator.suspend()
} }
func refreshInterface() {
coordinator.refreshInterface()
}
} }
private extension SceneDelegate { private extension SceneDelegate {