Fix jumping when restoring scroll position

This commit is contained in:
Justin Mazzocchi 2022-11-09 22:21:39 -08:00
parent 6518f8a19d
commit b7644cdd62
2 changed files with 9 additions and 1 deletions

View file

@ -59,6 +59,14 @@ final class TableViewDataSource: UITableViewDiffableDataSource<CollectionSection
}
}
override func applySnapshotUsingReloadData(
_ snapshot: NSDiffableDataSourceSnapshot<CollectionSection.Identifier, CollectionItem>,
completion: (() -> Void)? = nil) {
updateQueue.async {
super.applySnapshotUsingReloadData(snapshot, completion: completion)
}
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
let currentSnapshot = snapshot()
let section = currentSnapshot.sectionIdentifiers[section]

View file

@ -497,7 +497,7 @@ private extension TableViewController {
setPreviousOffset = true
}
self.dataSource.apply(update.sections.snapshot(), animatingDifferences: false) { [weak self] in
self.dataSource.applySnapshotUsingReloadData(update.sections.snapshot()) { [weak self] in
guard let self = self else { return }
if let itemId = update.maintainScrollPositionItemId,