History UI improvements

This commit is contained in:
James Magahern
2023-09-26 16:23:35 -07:00
parent d9fa5adf00
commit eec57f5f31
4 changed files with 36 additions and 6 deletions

View File

@@ -107,6 +107,15 @@ class BrowserHistory
}
}
public func clearAllHistory() {
let dataContext = persistentContainer.viewContext
let fetchRequest: NSFetchRequest<NSFetchRequestResult> = HistoryItemEntity.fetchRequest()
let request = NSBatchDeleteRequest(fetchRequest: fetchRequest)
do { try dataContext.execute(request) }
catch { print("Error clearing history: \(error.localizedDescription)") }
}
public func allHistory(filteredBy filterString: String? = nil, limit: Int = 500) -> [HistoryItem] {
let dataContext = persistentContainer.viewContext
let fetchRequest = fetchRequest(forStringContaining: filterString, limit: limit)