Skip to content

Commit

Permalink
Do not reload DBP tab when switching to it (#1942)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1203581873609357/1206115814306009/f

**Description**:
Do not reload the DBP tab when switching to it
  • Loading branch information
Bunn authored Dec 20, 2023
1 parent 19c06f2 commit be73f44
Showing 1 changed file with 17 additions and 1 deletion.
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

0 comments on commit be73f44

Please sign in to comment.