forked from shadowfacts/Tusker
Fix crash when inserting present items when there are no existing items
This commit is contained in:
parent
18d7917756
commit
b17b7b7a24
|
@ -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()!
|
||||
let firstVisibleItem = dataSource.itemIdentifier(for: firstVisibleIndexPath)!
|
||||
applySnapshot(snapshot, maintainingBottomRelativeScrollPositionOf: firstVisibleItem)
|
||||
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")
|
||||
|
|
Loading…
Reference in New Issue