Ensure proper cell layout

This commit is contained in:
Justin Mazzocchi 2021-03-12 11:09:40 -08:00
parent 9389e1c3b8
commit ac2d1fb805
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C

View file

@ -803,7 +803,7 @@ private extension TableViewController {
self.newItemsViewVisibleConstraint?.isActive = true
self.view.layoutIfNeeded()
} completion: { _ in
self.view.layoutIfNeeded()
self.reloadVisibleItems()
}
}
@ -814,8 +814,18 @@ private extension TableViewController {
self.newItemsViewVisibleConstraint?.isActive = false
self.view.layoutIfNeeded()
} completion: { _ in
self.view.layoutIfNeeded()
self.reloadVisibleItems()
}
}
func reloadVisibleItems() {
guard let visibleItems = tableView.indexPathsForVisibleRows?.compactMap(dataSource.itemIdentifier(for:))
else { return }
var snapshot = dataSource.snapshot()
snapshot.reloadItems(visibleItems)
dataSource.apply(snapshot, animatingDifferences: false)
}
}
// swiftlint:enable file_length