Fix crash due to Explore data source being update off main thread when list deleted

This commit is contained in:
Shadowfacts 2023-12-22 10:39:24 -05:00
parent e8576277e0
commit 43d8434e17
1 changed files with 6 additions and 3 deletions

View File

@ -261,13 +261,16 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
}
private func deleteList(_ list: List, completion: @escaping (Bool) -> Void) {
Task { @MainActor in
Task {
let service = DeleteListService(list: list, mastodonController: mastodonController, present: { self.present($0, animated: true) })
if await service.run() {
var snapshot = dataSource.snapshot()
snapshot.deleteItems([.list(list)])
await dataSource.apply(snapshot)
completion(true)
await MainActor.run {
dataSource.apply(snapshot, animatingDifferences: true) {
completion(true)
}
}
} else {
completion(false)
}