Skip to content

Commit

Permalink
Ref brave/brave-ios#3939: When deleting history, delete its Screen Ti…
Browse files Browse the repository at this point in the history
…me entry. (brave/brave-ios#8153)
  • Loading branch information
iccub committed Sep 26, 2023
1 parent 7d5c5fd commit 685d0e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import BraveCore
import Favicon
import UIKit
import DesignSystem
import ScreenTime

class HistoryViewController: SiteTableViewController, ToolbarUrlActionsProtocol {

Expand Down Expand Up @@ -293,6 +294,13 @@ class HistoryViewController: SiteTableViewController, ToolbarUrlActionsProtocol
// Reoving a history item should remove its corresponded Recently Closed item
RecentlyClosed.remove(with: historyItem.url.absoluteString)

do {
let screenTimeHistory = try STWebHistory(bundleIdentifier: Bundle.main.bundleIdentifier!)
screenTimeHistory.deleteHistory(for: historyItem.url)
} catch {
assertionFailure("STWebHistory could not be initialized: \(error)")
}

if isHistoryBeingSearched {
reloadDataAndShowLoading(with: searchQuery)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import BraveCore
import BraveShared
import CoreData
import Shared
import ScreenTime

extension BraveHistoryAPI {

Expand Down Expand Up @@ -54,9 +55,17 @@ extension BraveHistoryAPI {
}

func deleteAll(completion: @escaping () -> Void) {
var screenTimeHistory: STWebHistory?
do {
screenTimeHistory = try STWebHistory(bundleIdentifier: Bundle.main.bundleIdentifier!)
} catch {
assertionFailure("STWebHistory could not be initialized: \(error)")
}

DispatchQueue.main.async {
self.removeAll {
Domain.deleteNonBookmarkedAndClearSiteVisits() {
screenTimeHistory?.deleteAllHistory()
completion()
}
}
Expand Down

0 comments on commit 685d0e6

Please sign in to comment.