Skip to content

Commit

Permalink
Fix brave/brave-ios#7897: Clearing Out Data From Recently Closed Tabs (
Browse files Browse the repository at this point in the history
  • Loading branch information
JonKaleidoscope authored Aug 23, 2023
1 parent 8ab14c6 commit fb99b27
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 fb99b27

Please sign in to comment.