Fix potential crash due to race condition in timeline gap filling

This commit is contained in:
Shadowfacts 2023-10-28 14:03:08 -05:00
parent af5a0b7bbd
commit 37311e5f17
1 changed files with 7 additions and 1 deletions

View File

@ -1166,7 +1166,10 @@ extension TimelineViewController {
let addedItems: Bool
let statusItems = snapshot.itemIdentifiers(inSection: .statuses)
let gapIndex = statusItems.firstIndex(of: .gap)!
guard let gapIndex = statusItems.firstIndex(of: .gap) else {
// Not sure how this is reachable (maybe the gap cell was tapped twice and the requests raced?) but w/e
return
}
switch direction {
case .above:
@ -1293,6 +1296,9 @@ extension TimelineViewController: UICollectionViewDelegate {
selected(status: status.reblog?.id ?? id, state: collapseState.copy())
}
case .gap:
guard controller.state == .idle else {
return
}
let cell = collectionView.cellForItem(at: indexPath) as! TimelineGapCollectionViewCell
cell.showsIndicator = true
Task {