From 5fdbb8e579c068a54e9a397097d87063a3d8a146 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 10 May 2015 05:57:47 +0100 Subject: Search completion; rework SimpleCache. --- background_scripts/completion.coffee | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 94109b84..024ea54c 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -355,11 +355,14 @@ class TabCompleter tabRecency.recencyScore(suggestion.tabId) class SearchEngineCompleter - searchEngineConfig: null + searchEngines: null + + cancel: -> + CompletionEngines.cancel() refresh: (port) -> # Load and parse the search-engine configuration. - @searchEngineConfig = new AsyncDataFetcher (callback) -> + @searchEngines = new AsyncDataFetcher (callback) -> engines = {} for line in Settings.get("searchEngines").split "\n" line = line.trim() @@ -373,18 +376,18 @@ class SearchEngineCompleter searchUrl: tokens[1] description: description - # Deliver the resulting engines lookup table. + # Deliver the resulting engines AsyncDataFetcher lookup table. callback engines # Let the vomnibar know the custom search engine keywords. port.postMessage - handler: "customSearchEngineKeywords" + handler: "keywords" keywords: key for own key of engines filter: ({ queryTerms, query }, onComplete) -> return onComplete [] if queryTerms.length == 0 - @searchEngineConfig.use (engines) => + @searchEngines.use (engines) => keyword = queryTerms[0] { custom, searchUrl, description, queryTerms } = @@ -482,9 +485,6 @@ class SearchEngineCompleter count = Math.min 6, Math.max 3, MultiCompleter.maxResults - existingSuggestions.length onComplete suggestions[...count] - cancel: -> - CompletionEngines.cancel() - # A completer which calls filter() on many completers, aggregates the results, ranks them, and returns the top # 10. Queries from the vomnibar frontend script come through a multi completer. class MultiCompleter -- cgit v1.2.3