From 3e5c441b24cdf1e2b38abf9e85e925c82e668c53 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 9 May 2022 15:54:27 -0400 Subject: [PATCH] Fix crash when refreshing polls --- Tusker/Screens/Utilities/Previewing.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tusker/Screens/Utilities/Previewing.swift b/Tusker/Screens/Utilities/Previewing.swift index f7274c94..1f9f3d4c 100644 --- a/Tusker/Screens/Utilities/Previewing.swift +++ b/Tusker/Screens/Utilities/Previewing.swift @@ -213,7 +213,9 @@ extension MenuActionProvider { case .success(let status, _): // todo: this shouldn't really use the viewContext, but for some reason saving the // backgroundContext with the new version of the status isn't updating the viewContext - mastodonController.persistentContainer.addOrUpdate(status: status, context: mastodonController.persistentContainer.viewContext) + DispatchQueue.main.async { + mastodonController.persistentContainer.addOrUpdate(status: status, context: mastodonController.persistentContainer.viewContext) + } case .failure(let error): if let toastable = self?.toastableViewController { let config = ToastConfiguration(from: error, with: "Error Refreshing Poll", in: toastable, retryAction: nil)