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) { 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) }) let service = DeleteListService(list: list, mastodonController: mastodonController, present: { self.present($0, animated: true) })
if await service.run() { if await service.run() {
var snapshot = dataSource.snapshot() var snapshot = dataSource.snapshot()
snapshot.deleteItems([.list(list)]) snapshot.deleteItems([.list(list)])
await dataSource.apply(snapshot) await MainActor.run {
dataSource.apply(snapshot, animatingDifferences: true) {
completion(true) completion(true)
}
}
} else { } else {
completion(false) completion(false)
} }