From 56b1e6e937160e1ae08d75da8c79f8ab7a068983 Mon Sep 17 00:00:00 2001 From: Mariia Ganza Date: Tue, 2 Nov 2021 14:38:13 +0300 Subject: [PATCH 1/2] remove modals when the plugin is closed --- .../autoFind/contentScripts/contextMenu/contextmenu.js | 5 +++++ src/js/blocks/autoFind/contentScripts/highlight.js | 1 + .../contentScripts/reportProblemPopup/reportProblemPopup.js | 5 +++++ .../autoFind/contentScripts/settingsPopup/settingsPopup.js | 5 +++++ src/js/blocks/autoFind/utils/connector.js | 1 + 5 files changed, 17 insertions(+) diff --git a/src/js/blocks/autoFind/contentScripts/contextMenu/contextmenu.js b/src/js/blocks/autoFind/contentScripts/contextMenu/contextmenu.js index d395499b..0de02fd4 100644 --- a/src/js/blocks/autoFind/contentScripts/contextMenu/contextmenu.js +++ b/src/js/blocks/autoFind/contentScripts/contextMenu/contextmenu.js @@ -363,6 +363,11 @@ export const runContextMenu = () => { // ACTION: CLOSE MODAL modalCloseLink.addEventListener("click", () => modal.remove()); + chrome.storage.onChanged.addListener((event) => { + if (event?.IS_DISCONNECTED?.newValue === true && modal) { + modal.remove(); + } + }); }; // <----- diff --git a/src/js/blocks/autoFind/contentScripts/highlight.js b/src/js/blocks/autoFind/contentScripts/highlight.js index ac412e50..8aeb3ae1 100644 --- a/src/js/blocks/autoFind/contentScripts/highlight.js +++ b/src/js/blocks/autoFind/contentScripts/highlight.js @@ -290,6 +290,7 @@ export const highlightOnPage = () => { const disconnectHandler = () => { removeHighlight(() => console.log("JDN highlight has been killed"))(); + chrome.storage.sync.set({ IS_DISCONNECTED: true }); }; chrome.runtime.onConnect.addListener((p) => { diff --git a/src/js/blocks/autoFind/contentScripts/reportProblemPopup/reportProblemPopup.js b/src/js/blocks/autoFind/contentScripts/reportProblemPopup/reportProblemPopup.js index 12f03ddb..4e10c670 100644 --- a/src/js/blocks/autoFind/contentScripts/reportProblemPopup/reportProblemPopup.js +++ b/src/js/blocks/autoFind/contentScripts/reportProblemPopup/reportProblemPopup.js @@ -105,4 +105,9 @@ export const reportProblemPopup = () => { backgroundModal.append(modal); document.body.append(backgroundModal); + chrome.storage.onChanged.addListener((event) => { + if (event?.IS_DISCONNECTED?.newValue === true && modal) { + removePopup(); + } + }); }; diff --git a/src/js/blocks/autoFind/contentScripts/settingsPopup/settingsPopup.js b/src/js/blocks/autoFind/contentScripts/settingsPopup/settingsPopup.js index 5cc61895..545aa4f5 100644 --- a/src/js/blocks/autoFind/contentScripts/settingsPopup/settingsPopup.js +++ b/src/js/blocks/autoFind/contentScripts/settingsPopup/settingsPopup.js @@ -139,5 +139,10 @@ export const settingsPopup = () => { modal.appendChild(form); backgroundModal.append(modal); document.body.append(backgroundModal); + chrome.storage.onChanged.addListener((event) => { + if (event?.IS_DISCONNECTED?.newValue === true) { + removePopup(); + }; + }); }); }; diff --git a/src/js/blocks/autoFind/utils/connector.js b/src/js/blocks/autoFind/utils/connector.js index 42c3060e..b73f0c3c 100644 --- a/src/js/blocks/autoFind/utils/connector.js +++ b/src/js/blocks/autoFind/utils/connector.js @@ -117,6 +117,7 @@ class Connector { attachStaticScripts() { this.attachContentScript(highlightOnPage).then(() => { this.createPort(); + chrome.storage.sync.set({ IS_DISCONNECTED: false }); }); this.attachContentScript(runContextMenu); this.attachContentScript(highlightOrder); From 942761f295067372357fef1ca8c792da57383c25 Mon Sep 17 00:00:00 2001 From: Mariia Ganza Date: Tue, 2 Nov 2021 14:42:30 +0300 Subject: [PATCH 2/2] update version --- manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index d5960c34..5a550d36 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "JDN", "description": "", "devtools_page": "index.html", - "version": "3.0.70", + "version": "3.0.71", "permissions": [ "activeTab", "tabs", diff --git a/package.json b/package.json index 56d0ee5e..2f92ca99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jdi-react-extension", - "version": "3.0.70", + "version": "3.0.71", "description": "jdi react extension", "scripts": { "start": "npm run webpack",