Fix crash inserting present items when currentItems includes posts from since-unfollowed users
This commit is contained in:
parent
46cecde014
commit
a3e5b29cfc
|
@ -467,9 +467,19 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
return
|
||||
}
|
||||
let currentItems = snapshot.itemIdentifiers(inSection: .statuses)
|
||||
if case .status(id: let firstID, _, _) = currentItems.first,
|
||||
// if there's no overlap between presentItems and the existing items in the data source, prompt the user
|
||||
!presentItems.contains(firstID) {
|
||||
func currentItemsContains(id: String) -> Bool {
|
||||
return currentItems.contains { item in
|
||||
switch item {
|
||||
case .status(id: id, collapseState: _, filterState: _):
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
// if there's no overlap between presentItems and the existing items in the data source, prompt the user
|
||||
// we can't be clever here by just checking the first id in currentItems against presentItems, since that may belong to a since-unfollowed user
|
||||
if !presentItems.contains(where: { currentItemsContains(id: $0) }) {
|
||||
let applySnapshotBeforeScrolling: Bool
|
||||
|
||||
// remove any existing gap, if there is one
|
||||
|
|
Loading…
Reference in New Issue