Skip to content

Commit

Permalink
PB-33297 Extension update available should store the state if user si…
Browse files Browse the repository at this point in the history
…gned-in
  • Loading branch information
Benj1er committed May 7, 2024
1 parent fe56c6d commit 7deb6f1
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ 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
* @returns {Promise<void>}
*/
static async exec() {
if (await isUserAuthenticated()) {
this.shouldReload = true;
await browser.storage.session.set({[PASSBOLT_EXTENSION_UPDATE]: true});
} else {
await this.cleanAndReload();
}
Expand All @@ -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();
}
}
Expand Down

0 comments on commit 7deb6f1

Please sign in to comment.