diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-03-05 01:36:38 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-03-05 01:36:38 +0100 |
commit | 8cbef4c4c7a976967527234b6c3b6117b6de9808 (patch) | |
tree | 4f8d47dd0ba7e953245d19ca361f7477b785b121 /content_scripts/notify.js | |
parent | 1b2897c03b08e730a2e965e50bbd2104a7a81eef (diff) |
fix inadvertent double spending with coin selection
Diffstat (limited to 'content_scripts/notify.js')
-rw-r--r-- | content_scripts/notify.js | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/content_scripts/notify.js b/content_scripts/notify.js index 4768b09db..0719d5892 100644 --- a/content_scripts/notify.js +++ b/content_scripts/notify.js @@ -35,34 +35,16 @@ var TalerNotify; return url; } var handlers = []; - var connected = false; // Hack to know when the extension is unloaded - var port; - var connect = function (dh) { - port = chrome.runtime.connect(); - port.onDisconnect.addListener(dh); - chrome.runtime.sendMessage({ type: "ping" }, function () { - console.log("registering handlers"); - connected = true; - registerHandlers(); - }); - }; - var disconectHandler = function () { - if (connected) { - console.log("chrome runtime disconnected, removing handlers"); - for (var _i = 0, handlers_1 = handlers; _i < handlers_1.length; _i++) { - var handler = handlers_1[_i]; - document.removeEventListener(handler.type, handler.listener); - } - } - else { - // We got disconnected before the extension was ready, reconnect ... - window.setTimeout(function () { - connect(disconectHandler); - }, 200); + var port = chrome.runtime.connect(); + port.onDisconnect.addListener(function () { + console.log("chrome runtime disconnected, removing handlers"); + for (var _i = 0, handlers_1 = handlers; _i < handlers_1.length; _i++) { + var handler = handlers_1[_i]; + document.removeEventListener(handler.type, handler.listener); } - }; - connect(disconectHandler); + }); + registerHandlers(); function registerHandlers() { var $ = function (x) { return document.getElementById(x); }; function addHandler(type, listener) { |