aboutsummaryrefslogtreecommitdiff
path: root/background
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2021-07-20 11:19:37 +0200
committerWojtek Kosior <koszko@koszko.org>2021-07-20 11:19:37 +0200
commit9e26b71e8e6d2dd1c08d29972c96d3114b1bd24a (patch)
treef4ab2ee9cfd31a28e533df2f9773cf0378d487b0 /background
parent0c7c1ebddab49e1e0b1ad4cc4c8fcdeedd220946 (diff)
downloadbrowser-extension-9e26b71e8e6d2dd1c08d29972c96d3114b1bd24a.tar.gz
browser-extension-9e26b71e8e6d2dd1c08d29972c96d3114b1bd24a.zip
fix page info server bugs
Diffstat (limited to 'background')
-rw-r--r--background/message_server.js37
-rw-r--r--background/page_info_server.js9
2 files changed, 3 insertions, 43 deletions
diff --git a/background/message_server.js b/background/message_server.js
deleted file mode 100644
index a541a04..0000000
--- a/background/message_server.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Myext message server
- *
- * Copyright (C) 2021 Wojtek Kosior
- * Redistribution terms are gathered in the `copyright' file.
- */
-
-/*
- * IMPORTS_START
- * IMPORT browser
- * IMPORTS_END
- */
-
-var listeners = {};
-
-/* magic should be one of the constants from /common/connection_types.js */
-
-function listen_for_connection(magic, cb)
-{
- listeners[magic] = cb;
-}
-
-function raw_listen(port)
-{
- if (listeners[port.name] === undefined)
- return;
-
- listeners[port.name](port);
-}
-
-browser.runtime.onConnect.addListener(raw_listen);
-
-/*
- * EXPORTS_START
- * EXPORT listen_for_connection
- * EXPORTS_END
- */
diff --git a/background/page_info_server.js b/background/page_info_server.js
index 49919fd..6f02750 100644
--- a/background/page_info_server.js
+++ b/background/page_info_server.js
@@ -40,11 +40,6 @@ async function handle_subscription(connection_data, message)
connection_data.port.postMessage(["new_url", query_all(url)]);
}
-function remove_storage_listener(cb)
-{
- storage.remove_change_listener(cb);
-}
-
function new_connection(port)
{
console.log("new page info connection!");
@@ -59,7 +54,9 @@ function new_connection(port)
storage.add_change_listener(_handle_change);
port.onMessage.addListener(m => handle_subscription(connection_data, m));
- port.onDisconnect.addListener(() => remove_storage_listener(handle_change));
+ port.onDisconnect.addListener(
+ () => storage.remove_change_listener(_handle_change)
+ );
}
async function start_page_info_server()