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

Fix #7439: Update clear history app intent for SwiftUI #8501

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ extension BrowserViewController: TopToolbarDelegate {
feedDataSource: self.feedDataSource,
historyAPI: self.braveCore.historyAPI,
p3aUtilities: self.braveCore.p3aUtils,
clearDataCallback: { [weak self] isLoading in
clearDataCallback: { [weak self] isLoading, isHistoryCleared in
guard let view = self?.navigationController?.view, view.window != nil else {
assertionFailure()
return
Expand All @@ -416,6 +416,13 @@ extension BrowserViewController: TopToolbarDelegate {
spinner?.dismiss()
spinner = nil
}

if isHistoryCleared {
// Donate Clear Browser History for suggestions
let clearBrowserHistoryActivity = ActivityShortcutManager.shared.createShortcutActivity(type: .clearBrowsingHistory)
self?.userActivity = clearBrowserHistoryActivity
clearBrowserHistoryActivity.becomeCurrent()
}
}
))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ class HistoryViewController: SiteTableViewController, ToolbarUrlActionsProtocol

// Clearing History should clear Recently Closed
RecentlyClosed.removeAll()

// Donate Clear Browser History for suggestions
let clearBrowserHistoryActivity = ActivityShortcutManager.shared.createShortcutActivity(type: .clearBrowsingHistory)
self.userActivity = clearBrowserHistoryActivity
clearBrowserHistoryActivity.becomeCurrent()
}

// Asking Sync Engine To Remove Visits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import os
}
}

typealias ClearDataCallback = @MainActor (Bool) -> Void
typealias ClearDataCallback = @MainActor (Bool, Bool) -> Void
@Published var clearableSettings: [ClearableSetting]

private var subscriptions: [AnyCancellable] = []
Expand Down Expand Up @@ -106,12 +106,12 @@ import os
}

func clearPrivateData(_ clearables: [Clearable]) async {
clearDataCallback(true)
await clearPrivateDataInternal(clearables)
clearDataCallback(false)
clearDataCallback(true, false)
let isHistoryCleared = await clearPrivateDataInternal(clearables)
clearDataCallback(false, isHistoryCleared)
}

private func clearPrivateDataInternal(_ clearables: [Clearable]) async {
private func clearPrivateDataInternal(_ clearables: [Clearable]) async -> Bool {
@Sendable func _clear(_ clearables: [Clearable], secondAttempt: Bool = false) async {
await withThrowingTaskGroup(of: Void.self) { group in
for clearable in clearables {
Expand Down Expand Up @@ -176,6 +176,8 @@ import os
}

_toggleFolderAccessForBlockCookies(locked: true)

return historyCleared
}

private func registerSubscriptions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class SettingsViewController: TableViewController {
feedDataSource: self.feedDataSource,
historyAPI: self.historyAPI,
p3aUtilities: self.p3aUtilities,
clearDataCallback: { [weak self] isLoading in
clearDataCallback: { [weak self] isLoading, isHistoryCleared in
guard let view = self?.navigationController?.view, view.window != nil else {
assertionFailure()
return
Expand All @@ -259,6 +259,13 @@ class SettingsViewController: TableViewController {
spinner?.dismiss()
spinner = nil
}

if isHistoryCleared {
// Donate Clear Browser History for suggestions
let clearBrowserHistoryActivity = ActivityShortcutManager.shared.createShortcutActivity(type: .clearBrowsingHistory)
self?.userActivity = clearBrowserHistoryActivity
clearBrowserHistoryActivity.becomeCurrent()
}
}
))

Expand Down