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

search: use Firefox implementation for history search

  • Loading branch information
chrmod committed Jun 21, 2019
commit bcff3a0fa84d6c4d0fb5cff0f86f3686fcf0060b
@@ -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.