From 5fcd37872a5adb45c42e17a78b87d1e174e72908 Mon Sep 17 00:00:00 2001 From: Austin Siew <17107540+Aquafina-water-bottle@users.noreply.github.com> Date: Wed, 29 Mar 2023 20:32:40 -0600 Subject: fix: welcome page no longer loads multiple times --- ext/js/background/backend.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'ext/js/background') diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 5f42b4c9..a22371ed 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -239,7 +239,7 @@ class Backend { const options = this._getProfileOptions({current: true}); if (options.general.showGuide) { - this._openWelcomeGuidePage(); + this._openWelcomeGuidePageOnce(); } this._clipboardMonitor.on('change', this._onClipboardTextChange.bind(this)); @@ -2152,6 +2152,21 @@ class Backend { return textReplacements; } + async _openWelcomeGuidePageOnce() { + if (isObject(chrome.storage) && isObject(chrome.storage.session)) { + chrome.storage.session.get(["openedWelcomePage"]).then((result) => { + console.log(new Date(), "openedWelcomePage:", result["openedWelcomePage"]); + if (!result["openedWelcomePage"]) { + this._openWelcomeGuidePage(); + chrome.storage.session.set({"openedWelcomePage": true}); + } + }); + } else { + // likely not mv3 + this._openWelcomeGuidePage(); + } + } + async _openWelcomeGuidePage() { await this._createTab(chrome.runtime.getURL('/welcome.html')); } -- cgit v1.2.3 From 66521d3d16af4e15ba921aaf5d57e6ac331ea917 Mon Sep 17 00:00:00 2001 From: Austin Siew <17107540+Aquafina-water-bottle@users.noreply.github.com> Date: Wed, 29 Mar 2023 20:45:59 -0600 Subject: refactor: fixed linting errors --- ext/js/background/backend.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/js/background') diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index a22371ed..f3cb9548 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -2154,11 +2154,11 @@ class Backend { async _openWelcomeGuidePageOnce() { if (isObject(chrome.storage) && isObject(chrome.storage.session)) { - chrome.storage.session.get(["openedWelcomePage"]).then((result) => { - console.log(new Date(), "openedWelcomePage:", result["openedWelcomePage"]); - if (!result["openedWelcomePage"]) { + chrome.storage.session.get(['openedWelcomePage']).then((result) => { + console.log(new Date(), 'openedWelcomePage:', result.openedWelcomePage); + if (!result.openedWelcomePage) { this._openWelcomeGuidePage(); - chrome.storage.session.set({"openedWelcomePage": true}); + chrome.storage.session.set({'openedWelcomePage': true}); } }); } else { -- cgit v1.2.3 From 033d38d3a0dfabc2565769ff12e30145f5450eb5 Mon Sep 17 00:00:00 2001 From: Austin Siew <17107540+Aquafina-water-bottle@users.noreply.github.com> Date: Thu, 30 Mar 2023 00:55:20 -0600 Subject: refactor: added Firefox/Chrome comment on welcome page, removed console.log --- ext/js/background/backend.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ext/js/background') diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index f3cb9548..db6cfada 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -2154,15 +2154,17 @@ class Backend { async _openWelcomeGuidePageOnce() { if (isObject(chrome.storage) && isObject(chrome.storage.session)) { + // Chrome chrome.storage.session.get(['openedWelcomePage']).then((result) => { - console.log(new Date(), 'openedWelcomePage:', result.openedWelcomePage); if (!result.openedWelcomePage) { this._openWelcomeGuidePage(); chrome.storage.session.set({'openedWelcomePage': true}); } }); } else { - // likely not mv3 + // Firefox (storage.session is not supported yet) + // NOTE: This means that the welcome page will repeatedly open in Firefox + // until they support storage.session. this._openWelcomeGuidePage(); } } -- cgit v1.2.3