Fix crash when trying to reload/delete items not in current ItemsViewController
This commit is contained in:
parent
085f6043a6
commit
55e4966bd1
|
@ -104,10 +104,12 @@ class ItemsViewController: UIViewController {
|
|||
var snapshot = self.dataSource.snapshot()
|
||||
|
||||
if let updated = updated {
|
||||
snapshot.reconfigureItems(updated.compactMap { ($0 as? Item)?.objectID })
|
||||
let knownUpdated = updated.compactMap { ($0 as? Item)?.objectID }.filter { snapshot.itemIdentifiers.contains($0) }
|
||||
snapshot.reconfigureItems(knownUpdated)
|
||||
}
|
||||
if let deleted = deleted {
|
||||
snapshot.deleteItems(deleted.compactMap { ($0 as? Item)?.objectID })
|
||||
let knownDeleted = deleted.compactMap { ($0 as? Item)?.objectID }.filter { snapshot.itemIdentifiers.contains($0) }
|
||||
snapshot.deleteItems(knownDeleted)
|
||||
}
|
||||
|
||||
if let insertedItems = insertedItems {
|
||||
|
|
Loading…
Reference in New Issue