diff --git a/DuckDuckGo/Application/AppDelegate.swift b/DuckDuckGo/Application/AppDelegate.swift index 5d5d2fbe6c..6f0928275e 100644 --- a/DuckDuckGo/Application/AppDelegate.swift +++ b/DuckDuckGo/Application/AppDelegate.swift @@ -636,13 +636,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } } + @MainActor private func setUpAutoClearHandler() { - DispatchQueue.main.async { - self.autoClearHandler = AutoClearHandler(preferences: .shared, + let autoClearHandler = AutoClearHandler(preferences: .shared, fireViewModel: FireCoordinator.fireViewModel, - stateRestorationManager: self.stateRestorationManager) - self.autoClearHandler.handleAppLaunch() - self.autoClearHandler.onAutoClearCompleted = { + stateRestorationManager: self.stateRestorationManager) + self.autoClearHandler = autoClearHandler + DispatchQueue.main.async { + autoClearHandler.handleAppLaunch() + autoClearHandler.onAutoClearCompleted = { NSApplication.shared.reply(toApplicationShouldTerminate: true) } }