Only reset the timeline under certain conditions. Issue #1422

This commit is contained in:
Maurice Parker 2019-12-08 18:14:33 -07:00
parent 4ad7cd7bdd
commit 7a6b818f57
2 changed files with 15 additions and 15 deletions

View File

@ -73,7 +73,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
navigationItem.titleView = titleView
}
resetUI()
resetUI(resetScroll: true)
applyChanges(animated: false)
// Restore the scroll position if we have one stored
@ -163,8 +163,8 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
}
}
func reinitializeArticles() {
resetUI()
func reinitializeArticles(resetScroll: Bool) {
resetUI(resetScroll: resetScroll)
}
func reloadArticles(animated: Bool) {
@ -502,7 +502,7 @@ extension MasterTimelineViewController: UISearchBarDelegate {
private extension MasterTimelineViewController {
func resetUI() {
func resetUI(resetScroll: Bool) {
title = coordinator.timelineFeed?.nameForDisplay ?? "Timeline"
@ -535,7 +535,7 @@ private extension MasterTimelineViewController {
}
tableView.selectRow(at: nil, animated: false, scrollPosition: .top)
if dataSource.snapshot().itemIdentifiers(inSection: 0).count > 0 {
if resetScroll && dataSource.snapshot().itemIdentifiers(inSection: 0).count > 0 {
tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false)
}

View File

@ -436,7 +436,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
@objc func containerChildrenDidChange(_ note: Notification) {
if timelineFetcherContainsAnyPseudoFeed() || timelineFetcherContainsAnyFolder() {
refreshTimeline()
refreshTimeline(resetScroll: false)
}
rebuildBackingStores()
}
@ -460,7 +460,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
if timelineFetcherContainsAnyPseudoFeed() {
fetchAndReplaceArticlesAsync(animated: true) {
self.masterTimelineViewController?.reinitializeArticles()
self.masterTimelineViewController?.reinitializeArticles(resetScroll: false)
self.rebuildBackingStores() {
expandNewlyActivatedAccount()
}
@ -483,7 +483,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
if timelineFetcherContainsAnyPseudoFeed() {
fetchAndReplaceArticlesAsync(animated: true) {
self.masterTimelineViewController?.reinitializeArticles()
self.masterTimelineViewController?.reinitializeArticles(resetScroll: false)
self.rebuildBackingStores() {
expandNewAccount()
}
@ -505,7 +505,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
if timelineFetcherContainsAnyPseudoFeed() {
fetchAndReplaceArticlesAsync(animated: true) {
self.masterTimelineViewController?.reinitializeArticles()
self.masterTimelineViewController?.reinitializeArticles(resetScroll: false)
self.rebuildBackingStores() {
cleanupAccount()
}
@ -562,9 +562,9 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
return 0
}
func refreshTimeline() {
func refreshTimeline(resetScroll: Bool) {
fetchAndReplaceArticlesAsync(animated: true) {
self.masterTimelineViewController?.reinitializeArticles()
self.masterTimelineViewController?.reinitializeArticles(resetScroll: resetScroll)
}
}
@ -582,14 +582,14 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
if let feedID = timelineFeed?.feedID {
readFilterEnabledTable[feedID] = false
}
refreshTimeline()
refreshTimeline(resetScroll: false)
}
func hideReadArticles() {
if let feedID = timelineFeed?.feedID {
readFilterEnabledTable[feedID] = true
}
refreshTimeline()
refreshTimeline(resetScroll: false)
}
func isExpanded(_ node: Node) -> Bool {
@ -764,7 +764,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
func endSearching() {
if let ip = currentFeedIndexPath, let node = nodeFor(ip), let feed = node.representedObject as? Feed {
timelineFeed = feed
masterTimelineViewController?.reinitializeArticles()
masterTimelineViewController?.reinitializeArticles(resetScroll: true)
replaceArticles(with: savedSearchArticles!, animated: true)
} else {
setTimelineFeed(nil, animated: true)
@ -1264,7 +1264,7 @@ private extension SceneCoordinator {
timelineMiddleIndexPath = nil
fetchAndReplaceArticlesAsync(animated: animated) {
self.masterTimelineViewController?.reinitializeArticles()
self.masterTimelineViewController?.reinitializeArticles(resetScroll: true)
completion?()
}
}