Skip to content

Commit

Permalink
Ensure toast closures are called on the main thread (#3347)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlayterDev authored Sep 12, 2024
1 parent 90b9d3d commit 1b4e29a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1381,14 +1381,18 @@ class MainViewController: UIViewController {

private func makeBrokenSitePromptViewHostingController(event: UserBehaviorEvent) -> UIHostingController<BrokenSitePromptView> {
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)
}
Expand Down

0 comments on commit 1b4e29a

Please sign in to comment.