Fix crash when inserting present items when there are no existing items

This commit is contained in:
Shadowfacts 2023-01-02 17:18:30 -05:00
parent 18d7917756
commit b17b7b7a24
1 changed files with 6 additions and 3 deletions

View File

@ -621,9 +621,12 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
snapshot.insertItems(presentItems.map { .status(id: $0, collapseState: .unknown, filterState: .unknown) }, beforeItem: .gap)
if applySnapshotBeforeScrolling {
let firstVisibleIndexPath = collectionView.indexPathsForVisibleItems.min()!
if let firstVisibleIndexPath = collectionView.indexPathsForVisibleItems.min() {
let firstVisibleItem = dataSource.itemIdentifier(for: firstVisibleIndexPath)!
applySnapshot(snapshot, maintainingBottomRelativeScrollPositionOf: firstVisibleItem)
} else {
dataSource.apply(snapshot, animatingDifferences: false)
}
}
var config = ToastConfiguration(title: "Jump to Present")