Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement to email incontext behaviour when multiple windows are open #1455

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion DuckDuckGo/Tab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,27 @@ final class BrowserTabViewController: NSViewController {

@objc
private func onDuckDuckGoEmailIncontextSignup(_ notification: Notification) {
guard tabCollectionViewModel.selectedTab == WindowControllersManager.shared.selectedTab else {
return
}
self.previouslySelectedTab = tabCollectionViewModel.selectedTab
let tab = Tab(content: .url(EmailUrls().emailProtectionInContextSignupLink), shouldLoadInBackground: true)
let tab = Tab(content: .url(EmailUrls().emailProtectionInContextSignupLink), shouldLoadInBackground: false)
tabCollectionViewModel.append(tab: tab)
}

@objc
private func onCloseDuckDuckGoEmailProtection(_ notification: Notification) {
guard tabCollectionViewModel.selectedTab == WindowControllersManager.shared.selectedTab else {
return
}
guard let activeTab = tabCollectionViewModel.selectedTabViewModel?.tab else { return }
if activeTab.url != nil && EmailUrls().isDuckDuckGoEmailProtection(url: activeTab.url!) {
self.closeTab(activeTab)
}
if let previouslySelectedTab = self.previouslySelectedTab {
tabCollectionViewModel.select(tab: previouslySelectedTab)
if #available(macOS 11.0, *) {
os_log(.debug, "Tab %{private}s calling openAutofillAfterClosingEmailProtectionTab()", previouslySelectedTab.webView.url?.absoluteString ?? "with no url")
previouslySelectedTab.webView.evaluateJavaScript("window.openAutofillAfterClosingEmailProtectionTab()", in: nil, in: WKContentWorld.defaultClient)
}
self.previouslySelectedTab = nil
Expand Down