diff options
| author | Stephen Blott | 2015-05-02 14:30:25 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-02 14:31:01 +0100 |
| commit | 523a61edece5d025205dc77e52a007f0848a7f2c (patch) | |
| tree | 0dd42a44888b68d6a495bb22139ee25fb036e667 | |
| parent | 43d1e486ab44385fd18a408a148aeb0c6452fd1f (diff) | |
| download | vimium-523a61edece5d025205dc77e52a007f0848a7f2c.tar.bz2 | |
Fix vomnibar messaging.
This essentially reinstates 02ca5eafb6aca5a9a09b3b592be76d3b834ccde6,
however fixed properly this time.
| -rw-r--r-- | pages/vomnibar.coffee | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index f8ed0c78..ce0eb61c 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -171,6 +171,7 @@ class VomnibarUI # cancel scheduled update if (@updateTimer != null) window.clearTimeout(@updateTimer) + @updateTimer = null @updateCompletions(callback) else if (@updateTimer != null) # an update is already scheduled, don't do anything @@ -212,29 +213,30 @@ class BackgroundCompleter # - name: The background page completer that you want to interface with. Either "omni", "tabs", or # "bookmarks". */ constructor: (@name) -> - @filterPort = chrome.runtime.connect({ name: "filterCompleter" }) + @filterPort = chrome.runtime.connect name: "filterCompleter" refresh: -> - BackgroundCompleter.messageId += 1 - chrome.runtime.sendMessage({ handler: "refreshCompleter", name: @name }) + chrome.runtime.sendMessage handler: "refreshCompleter", name: @name filter: (query, callback) -> - @filterPort.onMessage.addListener (msg) => - @filterPort.onMessage.removeListener(arguments.callee) - if msg.id == BackgroundCompleter.messageId - # The result objects coming from the background page will be of the form: - # { html: "", type: "", url: "" } - # type will be one of [tab, bookmark, history, domain]. - results = msg.results.map (result) -> - functionToCall = if (result.type == "tab") - BackgroundCompleter.completionActions.switchToTab.curry(result.tabId) - else - BackgroundCompleter.completionActions.navigateToUrl.curry(result.url) - result.performAction = functionToCall - result - callback(results) - - @filterPort.postMessage({ id: ++BackgroundCompleter.messageId, name: @name, query: query }) + id = BackgroundCompleter.messageId += 1 + @filterPort.onMessage.addListener handler = (msg) => + if msg.id == id + @filterPort.onMessage.removeListener handler + if id == BackgroundCompleter.messageId + # The result objects coming from the background page will be of the form: + # { html: "", type: "", url: "" } + # type will be one of [tab, bookmark, history, domain]. + results = msg.results.map (result) -> + functionToCall = if (result.type == "tab") + BackgroundCompleter.completionActions.switchToTab.curry(result.tabId) + else + BackgroundCompleter.completionActions.navigateToUrl.curry(result.url) + result.performAction = functionToCall + result + callback(results) + + @filterPort.postMessage id: id, name: @name, query: query extend BackgroundCompleter, # |
