From 43d8434e17a285e203eeabb0d1a916aa4002d070 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 22 Dec 2023 10:39:24 -0500 Subject: [PATCH] Fix crash due to Explore data source being update off main thread when list deleted --- Tusker/Screens/Explore/ExploreViewController.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Tusker/Screens/Explore/ExploreViewController.swift b/Tusker/Screens/Explore/ExploreViewController.swift index 7c1f9384..3bebfc02 100644 --- a/Tusker/Screens/Explore/ExploreViewController.swift +++ b/Tusker/Screens/Explore/ExploreViewController.swift @@ -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) }