Enable prefetching on iOS 15 to improve Timeline scrolling speed

This commit is contained in:
Maurice Parker 2021-11-18 17:09:42 -06:00
parent 0d4f4054ce
commit 079e764f13
1 changed files with 15 additions and 6 deletions

View File

@ -83,10 +83,6 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
iconSize = AppDefaults.shared.timelineIconSize
resetEstimatedRowHeight()
if #available(iOS 15, *) {
tableView.isPrefetchingEnabled = false
}
if let titleView = Bundle.main.loadNibNamed("MasterTimelineTitleView", owner: self, options: nil)?[0] as? MasterTimelineTitleView {
navigationItem.titleView = titleView
}
@ -579,8 +575,12 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
}
@objc private func reloadAllVisibleCells() {
let visibleArticles = tableView.indexPathsForVisibleRows!.compactMap { return dataSource.itemIdentifier(for: $0) }
reloadCells(visibleArticles)
if #available(iOS 15, *) {
reconfigureCells(coordinator.articles)
} else {
let visibleArticles = tableView.indexPathsForVisibleRows!.compactMap { return dataSource.itemIdentifier(for: $0) }
reloadCells(visibleArticles)
}
}
private func reloadCells(_ articles: [Article]) {
@ -590,6 +590,15 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
self?.restoreSelectionIfNecessary(adjustScroll: false)
}
}
private func reconfigureCells(_ articles: [Article]) {
guard #available(iOS 15, *) else { return }
var snapshot = dataSource.snapshot()
snapshot.reconfigureItems(articles)
dataSource.apply(snapshot, animatingDifferences: false) { [weak self] in
self?.restoreSelectionIfNecessary(adjustScroll: false)
}
}
// MARK: Cell Configuring