Fix crash when displaying search results
This commit is contained in:
parent
986fc5b833
commit
641ab765a7
|
@ -134,14 +134,18 @@ class SearchResultsViewController: EnhancedTableViewController {
|
||||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||||
|
|
||||||
self.mastodonController.persistentContainer.performBatchUpdates({ (context, addAccounts, addStatuses) in
|
self.mastodonController.persistentContainer.performBatchUpdates({ (context, addAccounts, addStatuses) in
|
||||||
oldSnapshot.itemIdentifiers(inSection: .accounts).forEach { (item) in
|
if oldSnapshot.indexOfSection(.accounts) != nil {
|
||||||
guard case let .account(id) = item else { return }
|
oldSnapshot.itemIdentifiers(inSection: .accounts).forEach { (item) in
|
||||||
self.mastodonController.persistentContainer.account(for: id, in: context)?.decrementReferenceCount()
|
guard case let .account(id) = item else { return }
|
||||||
|
self.mastodonController.persistentContainer.account(for: id, in: context)?.decrementReferenceCount()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
oldSnapshot.itemIdentifiers(inSection: .statuses).forEach { (item) in
|
if oldSnapshot.indexOfSection(.statuses) != nil {
|
||||||
guard case let .status(id, _) = item else { return }
|
oldSnapshot.itemIdentifiers(inSection: .statuses).forEach { (item) in
|
||||||
self.mastodonController.persistentContainer.status(for: id, in: context)?.decrementReferenceCount()
|
guard case let .status(id, _) = item else { return }
|
||||||
|
self.mastodonController.persistentContainer.status(for: id, in: context)?.decrementReferenceCount()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.onlySections.contains(.accounts) && !results.accounts.isEmpty {
|
if self.onlySections.contains(.accounts) && !results.accounts.isEmpty {
|
||||||
|
|
Loading…
Reference in New Issue