Fix sendRemoveListener on closed conduit when unloading a page (#312)

* Update simple-translate.js

* Update background.js

* Update manifest.json

* Delete background.js

* Delete manifest.json

* Delete simple-translate.js

* Update index.js
This commit is contained in:
def00111 2021-07-06 18:00:39 +02:00 committed by GitHub
parent 8606f1e347
commit b5d5970a85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@ const init = async () => {
await initSettings();
document.addEventListener("mouseup", handleMouseUp);
document.addEventListener("keydown", handleKeyDown);
window.addEventListener("unload", onUnload, { once: true });
browser.storage.onChanged.addListener(handleSettingsChange);
browser.runtime.onMessage.addListener(handleMessage);
overWriteLogLevel();
@ -132,6 +133,10 @@ const handleKeyDown = e => {
}
};
const onUnload = () => {
browser.storage.onChanged.removeListener(handleSettingsChange);
};
let isEnabled = true;
const handleMessage = async request => {
const empty = new Promise(resolve => {