From 1b4e29a3d732fc8e6cc2a1d78a45bcecf729badd Mon Sep 17 00:00:00 2001 From: Brad Slayter Date: Thu, 12 Sep 2024 16:01:25 -0500 Subject: [PATCH] Ensure toast closures are called on the main thread (#3347) --- DuckDuckGo/MainViewController.swift | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index ca18ab0e12..edf27a7393 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -1381,14 +1381,18 @@ class MainViewController: UIViewController { private func makeBrokenSitePromptViewHostingController(event: UserBehaviorEvent) -> UIHostingController { let viewModel = BrokenSitePromptViewModel(onDidDismiss: { [weak self] in - self?.hideNotification() - self?.brokenSitePromptLimiter.didDismissToast() - self?.brokenSitePromptViewHostingController = nil + Task { @MainActor in + self?.hideNotification() + self?.brokenSitePromptLimiter.didDismissToast() + self?.brokenSitePromptViewHostingController = nil + } }, onDidSubmit: { [weak self] in - self?.segueToReportBrokenSite(entryPoint: .prompt(event.rawValue)) - self?.hideNotification() - self?.brokenSitePromptLimiter.didOpenReport() - self?.brokenSitePromptViewHostingController = nil + Task { @MainActor in + self?.segueToReportBrokenSite(entryPoint: .prompt(event.rawValue)) + self?.hideNotification() + self?.brokenSitePromptLimiter.didOpenReport() + self?.brokenSitePromptViewHostingController = nil + } }) return UIHostingController(rootView: BrokenSitePromptView(viewModel: viewModel), ignoreSafeArea: true) }