From 1e75e0f187990caeedf2c2e4f107920b0ef2d12e Mon Sep 17 00:00:00 2001 From: Brandon T Date: Thu, 15 Jun 2023 15:15:53 -0400 Subject: [PATCH] Fix private-tab mode message not showing all the time. Fix private tab deleting when exiting persistence mode. --- .../Frontend/Browser/Tabs/TabTray/TabTrayController.swift | 2 +- .../Shields/OtherPrivacySettingsSectionView.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift b/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift index 5e235848cde..bdf93c177d8 100644 --- a/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift +++ b/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift @@ -603,7 +603,7 @@ class TabTrayController: LoadingViewController { tabTypeSelector.selectedSegmentIndex = 0 tabTypeSelector.sendActions(for: UIControl.Event.valueChanged) - if !Preferences.Privacy.persistentPrivateBrowsing.value { + if !Preferences.Privacy.persistentPrivateBrowsing.value || tabManager.tabsForCurrentMode.isEmpty { tabTrayView.showPrivateModeInfo() // New private tab is created immediately to reflect changes on NTP. // If user drags the modal down or dismisses it, a new private tab will be ready. diff --git a/Sources/Brave/Frontend/Settings/Shields/OtherPrivacySettingsSectionView.swift b/Sources/Brave/Frontend/Settings/Shields/OtherPrivacySettingsSectionView.swift index 721e8dd139c..f214e228fe4 100644 --- a/Sources/Brave/Frontend/Settings/Shields/OtherPrivacySettingsSectionView.swift +++ b/Sources/Brave/Frontend/Settings/Shields/OtherPrivacySettingsSectionView.swift @@ -63,10 +63,10 @@ struct OtherPrivacySettingsSectionView: View { settings.tabManager.saveAllTabs() } else { let tabs = settings.tabManager.allTabs.filter({ $0.isPrivate }) - if settings.tabManager.privateBrowsingManager.isPrivateBrowsing { - SessionTab.deleteAll(tabIds: tabs.map({ $0.id })) - } else { - settings.tabManager.removeTabs(tabs) + SessionTab.deleteAll(tabIds: tabs.map({ $0.id })) + + if !settings.tabManager.privateBrowsingManager.isPrivateBrowsing { + settings.tabManager.willSwitchTabMode(leavingPBM: true) } } }