Prevent scrolling while reloading cells Issue #1085
This commit is contained in:
parent
56cdac6519
commit
1f26a91af9
|
@ -137,9 +137,13 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
|||
|
||||
// MARK: API
|
||||
|
||||
func restoreSelectionIfNecessary() {
|
||||
func restoreSelectionIfNecessary(adjustScroll: Bool) {
|
||||
if let article = coordinator.currentArticle, let indexPath = dataSource.indexPath(for: article) {
|
||||
tableView.selectRowAndScrollIfNotVisible(at: indexPath, animated: false, deselect: coordinator.isRootSplitCollapsed)
|
||||
if adjustScroll {
|
||||
tableView.selectRowAndScrollIfNotVisible(at: indexPath, animated: false, deselect: coordinator.isRootSplitCollapsed)
|
||||
} else {
|
||||
tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,7 +394,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
|||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reloadItems(articles)
|
||||
dataSource.apply(snapshot, animatingDifferences: false) { [weak self] in
|
||||
self?.restoreSelectionIfNecessary()
|
||||
self?.restoreSelectionIfNecessary(adjustScroll: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,7 +511,7 @@ private extension MasterTimelineViewController {
|
|||
snapshot.appendItems(coordinator.articles, toSection: 0)
|
||||
|
||||
dataSource.apply(snapshot, animatingDifferences: animate) { [weak self] in
|
||||
self?.restoreSelectionIfNecessary()
|
||||
self?.restoreSelectionIfNecessary(adjustScroll: false)
|
||||
completion?()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1516,7 +1516,7 @@ private extension SceneCoordinator {
|
|||
subSplitViewController!.showDetailViewController(navController, sender: self)
|
||||
|
||||
masterFeedViewController.restoreSelectionIfNecessary(adjustScroll: true)
|
||||
masterTimelineViewController!.restoreSelectionIfNecessary()
|
||||
masterTimelineViewController!.restoreSelectionIfNecessary(adjustScroll: true)
|
||||
|
||||
// We made sure this was there above when we called configureDoubleSplit
|
||||
return subSplitViewController!
|
||||
|
|
Loading…
Reference in New Issue