Skip to content

Commit

Permalink
fix SettingsVC readding on pane change; fix native ui session restora…
Browse files Browse the repository at this point in the history
…tion losing forward history and re-restoring
  • Loading branch information
mallexxx committed Feb 22, 2024
1 parent 3dad84b commit 5ba0ccb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion DuckDuckGo/Tab/Model/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,13 @@ protocol NewWindowPolicyDecisionMaker {

@MainActor
private func shouldReload(_ url: URL, shouldLoadInBackground: Bool) -> Bool {
var isNativeUI: Bool {
let content = TabContent.contentFromURL(url, source: .ui)
return !content.isUrl && content.urlForWebView != nil
}
// don‘t reload in background unless shouldLoadInBackground
guard url.isValid,
webView.superview != nil || shouldLoadInBackground,
webView.superview != nil || shouldLoadInBackground || isNativeUI,
// don‘t reload when already loaded
webView.url != url || error != nil else { return false }

Expand Down
9 changes: 6 additions & 3 deletions DuckDuckGo/Tab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,16 @@ final class BrowserTabViewController: NSViewController {
addAndLayoutChild(bookmarksViewControllerCreatingIfNeeded())

case let .settings(pane):
removeAllTabContent()
let preferencesViewController = preferencesViewControllerCreatingIfNeeded()
if preferencesViewController.parent !== self {
removeAllTabContent()
}
if let pane = pane, preferencesViewController.model.selectedPane != pane {
preferencesViewController.model.selectPane(pane)
}
addAndLayoutChild(preferencesViewController)

if preferencesViewController.parent !== self {
addAndLayoutChild(preferencesViewController)
}
case .onboarding:
removeAllTabContent()
if !OnboardingViewModel.isOnboardingFinished {
Expand Down

0 comments on commit 5ba0ccb

Please sign in to comment.