Skip to content
This repository has been archived by the owner. It is now read-only.

search: use Firefox implementation for history search #356

Merged
merged 1 commit into from Jun 24, 2019
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -49,22 +49,27 @@ open class BrowserActions: RCTEventEmitter {
}

@objc(searchHistory:callback:)
func searchHistory(query: NSString, callback: RCTResponseSenderBlock) {
func searchHistory(query: NSString, callback: @escaping RCTResponseSenderBlock) {
debugPrint("searchHistory")
callback([getHistory()])
}

func getHistory() -> [[String: String]] {
var results: [[String: String]] = []
if let r = HistoryListener.shared.historyResults {
for site in r {
if let siteUrl = site?.url, let url = URL(string: siteUrl), !isDuckduckGoRedirectURL(url) {
let d = ["url": site!.url, "title": site!.title]
results.append(d)
DispatchQueue.main.async {
if let appDel = UIApplication.shared.delegate as? AppDelegate {
if let profile = appDel.profile {
var results: [[String: String]] = []
let frecentHistory = profile.history.getFrecentHistory()
frecentHistory.getSites(whereURLContains: query as String, historyLimit: 100, bookmarksLimit: 5)
>>== { (sites: Cursor) in
for site in sites {
if let siteUrl = site?.url, let url = URL(string: siteUrl), !self.isDuckduckGoRedirectURL(url) {
let d = ["url": site!.url, "title": site!.title]
results.append(d)
}
}
callback([results])
}
}
}
}
return results
}

private func isDuckduckGoRedirectURL(_ url: URL) -> Bool {
ProTip! Use n and p to navigate between commits in a pull request.