Skip to content

Commit

Permalink
handle auto clear on load url
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy committed Apr 3, 2024
1 parent aa47182 commit 835d9b7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/AutoClear.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
7 changes: 7 additions & 0 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -2291,6 +2294,10 @@ extension MainViewController: AutoClearWorker {
}

func refreshUIAfterClear() {
guard doRefreshAfterClear else {
doRefreshAfterClear = true
return
}
showBars()
attachHomeScreen()
tabsBarController?.refresh(tabsModel: tabManager.model)
Expand Down

0 comments on commit 835d9b7

Please sign in to comment.