diff --git a/DuckDuckGo/AppDelegate.swift b/DuckDuckGo/AppDelegate.swift index 70054f97c8..af928fb050 100644 --- a/DuckDuckGo/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate.swift @@ -753,7 +753,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } Task { @MainActor in - await autoClear?.applicationWillMoveToForeground() + // Autoclear should have happened by now showKeyboardIfSettingOn = false if !handleAppDeepLink(app, mainViewController, url) { diff --git a/DuckDuckGo/AutoClear.swift b/DuckDuckGo/AutoClear.swift index 134b23d683..bda1c46614 100644 --- a/DuckDuckGo/AutoClear.swift +++ b/DuckDuckGo/AutoClear.swift @@ -87,8 +87,8 @@ class AutoClear { let timestamp = timestamp, shouldClearData(elapsedTime: Date().timeIntervalSince1970 - timestamp) else { return } + self.timestamp = nil worker.clearNavigationStack() await clearData() - self.timestamp = nil } } diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 4f25492fe5..db0a80f093 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -89,6 +89,8 @@ class MainViewController: UIViewController { let appSettings: AppSettings private var launchTabObserver: LaunchTabNotification.Observer? + var doRefreshAfterClear = true + #if APP_TRACKING_PROTECTION private let appTrackingProtectionDatabase: CoreDataDatabase #endif @@ -866,6 +868,7 @@ class MainViewController: UIViewController { selectTab(existing) return } else if reuseExisting, let existing = tabManager.firstHomeTab() { + doRefreshAfterClear = false tabManager.selectTab(existing) loadUrl(url, fromExternalLink: fromExternalLink) } else { @@ -2291,6 +2294,10 @@ extension MainViewController: AutoClearWorker { } func refreshUIAfterClear() { + guard doRefreshAfterClear else { + doRefreshAfterClear = true + return + } showBars() attachHomeScreen() tabsBarController?.refresh(tabsModel: tabManager.model)