Fix crash when trying to reload/delete items not in current ItemsViewController

This commit is contained in:
Shadowfacts 2022-02-09 10:04:26 -05:00
parent 085f6043a6
commit 55e4966bd1
1 changed files with 4 additions and 2 deletions

View File

@ -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 {