Fix crash when inserting present items in empty timeline

This commit is contained in:
Shadowfacts 2023-01-21 16:31:52 -05:00
parent dd6813c058
commit c6043d60ee
1 changed files with 5 additions and 1 deletions

View File

@ -719,7 +719,11 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
// there is no existing gap
applySnapshotBeforeScrolling = true
}
snapshot.insertItems([.gap], beforeItem: currentItems.first!)
if let first = currentItems.first {
snapshot.insertItems([.gap], beforeItem: first)
} else {
snapshot.appendItems([.gap], toSection: .statuses)
}
snapshot.insertItems(presentItems.map { .status(id: $0, collapseState: .unknown, filterState: .unknown) }, beforeItem: .gap)
if applySnapshotBeforeScrolling {