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

Do not reload DBP tab when switching to it #1942

Merged
merged 7 commits into from
Dec 20, 2023
Merged
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
18 changes: 17 additions & 1 deletion DuckDuckGo/Tab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,30 @@ final class BrowserTabViewController: NSViewController {
tabCollectionViewModel.tabCollection.$tabs
.sink(receiveValue: setDelegate())
.store(in: &cancellables)

tabCollectionViewModel.tabCollection.$tabs
.sink(receiveValue: removeDataBrokerViewIfNecessary())
.store(in: &cancellables)
}

private func subscribeToPinnedTabs() {
pinnedTabsDelegatesCancellable = tabCollectionViewModel.pinnedTabsCollection?.$tabs
.sink(receiveValue: setDelegate())
}

private func removeDataBrokerViewIfNecessary() -> ([Tab]) -> Void {
{ [weak self] (tabs: [Tab]) in
guard let self else { return }
#if DBP
if let dataBrokerProtectionHomeViewController,
!tabs.contains(where: { $0.content == .dataBrokerProtection }) {
dataBrokerProtectionHomeViewController.removeCompletely()
self.dataBrokerProtectionHomeViewController = nil
}
#endif
}
}

private func setDelegate() -> ([Tab]) -> Void {
{ [weak self] (tabs: [Tab]) in
guard let self else { return }
Expand Down Expand Up @@ -431,7 +448,6 @@ final class BrowserTabViewController: NSViewController {
bookmarksViewController?.removeCompletely()
#if DBP
dataBrokerProtectionHomeViewController?.removeCompletely()
dataBrokerProtectionHomeViewController = nil
#endif
if includingWebView {
self.removeWebViewFromHierarchy()
Expand Down
Loading