Skip to content

Commit

Permalink
Open new browser window if no windows exist (#2610)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1203137811378537/1207061568595472/f
Tech Design URL:
CC:

**Description**:

Fixes an issue when "Open DDG" doesn't create a new window if none
existing window is found.

**Steps to test this PR**:
1. With at least one DDG opened and in the background, open status bar
menu > Open DDG
2. Expect: DDG is brought to the foreground
3. Close all DDG windows
4. Open status bar menu > Open DDG
5. Expect: New DDG window is created

<!--
Tagging instructions
If this PR isn't ready to be merged for whatever reason it should be
marked with the `DO NOT MERGE` label (particularly if it's a draft)
If it's pending Product Review/PFR, please add the `Pending Product
Review` label.

If at any point it isn't actively being worked on/ready for
review/otherwise moving forward (besides the above PR/PFR exception)
strongly consider closing it (or not opening it in the first place). If
you decide not to close it, make sure it's labelled to make it clear the
PRs state and comment with more information.
-->

---
###### Internal references:
[Pull Request Review
Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f)
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
[Pull Request
Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f)
  • Loading branch information
quanganhdo authored Apr 12, 2024
1 parent 13d488e commit 22cddbc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions DuckDuckGo/Application/URLEventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ final class URLEventHandler {
WindowControllersManager.shared.showPreferencesTab(withSelectedPane: .vpn)
case AppLaunchCommand.shareFeedback.launchURL:
WindowControllersManager.shared.showShareFeedbackModal()
case AppLaunchCommand.justOpen.launchURL:
WindowControllersManager.shared.showNewWindow()
case AppLaunchCommand.showVPNLocations.launchURL:
WindowControllersManager.shared.showPreferencesTab(withSelectedPane: .vpn)
WindowControllersManager.shared.showLocationPickerSheet()
Expand Down
7 changes: 7 additions & 0 deletions DuckDuckGo/Windows/View/WindowControllersManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ extension WindowControllersManager {
}
}

func showNewWindow() {
guard WindowControllersManager.shared.lastKeyMainWindowController == nil else { return }
let tabCollection = TabCollection(tabs: [])
let tabCollectionViewModel = TabCollectionViewModel(tabCollection: tabCollection)
_ = WindowsManager.openNewWindow(with: tabCollectionViewModel)
}

func showLocationPickerSheet() {
let locationsViewController = VPNLocationsHostingViewController()
let locationsWindowController = locationsViewController.wrappedInWindowController()
Expand Down

0 comments on commit 22cddbc

Please sign in to comment.