From 7deb6f16b33e48c665ddc62c5ab6c20597238274 Mon Sep 17 00:00:00 2001 From: Benjamin Monnot Date: Tue, 7 May 2024 12:19:40 +0200 Subject: [PATCH] PB-33297 Extension update available should store the state if user signed-in --- .../extension/onExtensionUpdateAvailableService.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/all/background_page/service/extension/onExtensionUpdateAvailableService.js b/src/all/background_page/service/extension/onExtensionUpdateAvailableService.js index cdfc3928..a8cf83f9 100644 --- a/src/all/background_page/service/extension/onExtensionUpdateAvailableService.js +++ b/src/all/background_page/service/extension/onExtensionUpdateAvailableService.js @@ -20,6 +20,8 @@ import WebIntegrationPagemod from "../../pagemod/webIntegrationPagemod"; import WorkerService from "../worker/workerService"; import PublicWebsiteSignInPagemod from "../../pagemod/publicWebsiteSignInPagemod"; +const PASSBOLT_EXTENSION_UPDATE = "passboltExtensionUpdate"; + class OnExtensionUpdateAvailableService { /** * Execute the OnExtensionUpdateAvailableService process @@ -27,7 +29,7 @@ class OnExtensionUpdateAvailableService { */ static async exec() { if (await isUserAuthenticated()) { - this.shouldReload = true; + await browser.storage.session.set({[PASSBOLT_EXTENSION_UPDATE]: true}); } else { await this.cleanAndReload(); } @@ -47,8 +49,9 @@ class OnExtensionUpdateAvailableService { * It triggers a runtime reload if an extension update was available while the user was signed in. */ static async handleUserLoggedOut() { - if (this.shouldReload) { - this.shouldReload = false; + const shouldUpdate = await browser.storage.session.get(PASSBOLT_EXTENSION_UPDATE); + if (shouldUpdate && shouldUpdate[PASSBOLT_EXTENSION_UPDATE]) { + await browser.storage.session.remove(PASSBOLT_EXTENSION_UPDATE); await this.cleanAndReload(); } }