Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #7897: Clearing Out Data From Recently Closed Tabs (#7919)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonKaleidoscope authored Aug 23, 2023
1 parent 95556f5 commit aa97c1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,21 @@ extension BrowserViewController: TabManagerDelegate {
// After opening the Recently Closed in a new tab delete it from list
RecentlyClosed.remove(with: recentlyClosed.url)
}

recentlyClosedTabsView.onClearAllRecentlyClosed = { [weak self] in
// After clearing tabs need to remove button actions from the tab bar controls
guard let self = self else { return }

DispatchQueue.main.async {
self.updateToolbarUsingTabManager(tabManager)
}
}

self.present(UIHostingController(rootView: recentlyClosedTabsView), animated: true)
})

recentlyClosedMenuChildren.append(viewRecentlyClosedTabs)

// Fetch last item in Recently Closed
if let recentlyClosedTab = RecentlyClosed.all().first {
recentlyClosedMenuChildren.append(viewRecentlyClosedTabs)
let reopenLastClosedTab = UIAction(
title: Strings.RecentlyClosed.recentlyClosedReOpenLastActionTitle,
image: UIImage(braveSystemNamed: "leo.browser.mobile-tab-ntp"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct RecentlyClosedTabsView: View {

@State private var showClearDataPrompt: Bool = false
var onRecentlyClosedSelected: ((RecentlyClosed) -> Void)?
var onClearAllRecentlyClosed: (() -> Void)?

private let tabManager: TabManager?

Expand All @@ -30,13 +31,14 @@ struct RecentlyClosedTabsView: View {
.foregroundColor(Color(.braveBlurpleTint))
.actionSheet(isPresented: $showClearDataPrompt) {
.init(title: Text(Strings.RecentlyClosed.recentlyClosedClearActionConfirmation),
buttons: [
.destructive(Text(Strings.RecentlyClosed.recentlyClosedClearActionTitle), action: {
RecentlyClosed.removeAll()
dismissView()
}),
.cancel()
]
buttons: [
.destructive(Text(Strings.RecentlyClosed.recentlyClosedClearActionTitle), action: {
RecentlyClosed.removeAll()
onClearAllRecentlyClosed?()
dismissView()
}),
.cancel()
]
)
}
}
Expand Down

0 comments on commit aa97c1c

Please sign in to comment.