From e673e224d811eec7311f50371d050c9920771039 Mon Sep 17 00:00:00 2001 From: martgil Date: Wed, 9 Oct 2024 14:36:15 +0800 Subject: [PATCH 1/3] Reduce GlobalStore accounts in addition to sessionStorage removal --- extension/js/common/platform/store/global-store.ts | 6 ++++-- extension/js/common/settings.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/extension/js/common/platform/store/global-store.ts b/extension/js/common/platform/store/global-store.ts index 6e48624e23a..76749b2f92d 100644 --- a/extension/js/common/platform/store/global-store.ts +++ b/extension/js/common/platform/store/global-store.ts @@ -94,10 +94,12 @@ export class GlobalStore extends AbstractStore { } } - public static async acctEmailsRemove(acctEmail: string): Promise { + public static async acctEmailsRemove(acctEmail: string, softReset = false): Promise { // todo: concurrency issues with another tab loaded at the same time const acctEmails = await GlobalStore.acctEmailsGet(); await GlobalStore.set({ account_emails: JSON.stringify(Value.arr.withoutVal(acctEmails, acctEmail)) }); // eslint-disable-line @typescript-eslint/naming-convention - BrowserMsg.send.bg.updateUninstallUrl(); + if (!softReset) { + BrowserMsg.send.bg.updateUninstallUrl(); + } } } diff --git a/extension/js/common/settings.ts b/extension/js/common/settings.ts index a50b930f189..b68db5acf42 100644 --- a/extension/js/common/settings.ts +++ b/extension/js/common/settings.ts @@ -87,6 +87,8 @@ export class Settings { const acctEmails = await GlobalStore.acctEmailsGet(); if (!acctEmails.includes(acctEmail)) { throw new Error(`"${acctEmail}" is not a known account_email in "${JSON.stringify(acctEmails)}"`); + } else { + await GlobalStore.acctEmailsRemove(acctEmail, true); } const storageIndexesToRemove: AccountIndex[] = []; const filter = AbstractStore.singleScopeRawIndex(acctEmail, ''); From 1c34149e29221284f2eef857ac2ce4a9c606d154 Mon Sep 17 00:00:00 2001 From: martgil Date: Wed, 9 Oct 2024 14:51:33 +0800 Subject: [PATCH 2/3] use better variable names --- extension/js/common/platform/store/global-store.ts | 4 ++-- extension/js/common/settings.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extension/js/common/platform/store/global-store.ts b/extension/js/common/platform/store/global-store.ts index 76749b2f92d..44c1e79035d 100644 --- a/extension/js/common/platform/store/global-store.ts +++ b/extension/js/common/platform/store/global-store.ts @@ -94,11 +94,11 @@ export class GlobalStore extends AbstractStore { } } - public static async acctEmailsRemove(acctEmail: string, softReset = false): Promise { + public static async acctEmailsRemove(acctEmail: string, openUninstallUrl = true): Promise { // todo: concurrency issues with another tab loaded at the same time const acctEmails = await GlobalStore.acctEmailsGet(); await GlobalStore.set({ account_emails: JSON.stringify(Value.arr.withoutVal(acctEmails, acctEmail)) }); // eslint-disable-line @typescript-eslint/naming-convention - if (!softReset) { + if (openUninstallUrl) { BrowserMsg.send.bg.updateUninstallUrl(); } } diff --git a/extension/js/common/settings.ts b/extension/js/common/settings.ts index b68db5acf42..bc804f41ddd 100644 --- a/extension/js/common/settings.ts +++ b/extension/js/common/settings.ts @@ -88,7 +88,7 @@ export class Settings { if (!acctEmails.includes(acctEmail)) { throw new Error(`"${acctEmail}" is not a known account_email in "${JSON.stringify(acctEmails)}"`); } else { - await GlobalStore.acctEmailsRemove(acctEmail, true); + await GlobalStore.acctEmailsRemove(acctEmail, false); } const storageIndexesToRemove: AccountIndex[] = []; const filter = AbstractStore.singleScopeRawIndex(acctEmail, ''); From 0a5dcc281f135fbd26823d70fdf6fb92a7fb1e43 Mon Sep 17 00:00:00 2001 From: martgil Date: Thu, 10 Oct 2024 09:38:19 +0800 Subject: [PATCH 3/3] pr reviews: apply corrections --- extension/js/common/platform/store/global-store.ts | 6 ++---- extension/js/common/settings.ts | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/extension/js/common/platform/store/global-store.ts b/extension/js/common/platform/store/global-store.ts index 44c1e79035d..6e48624e23a 100644 --- a/extension/js/common/platform/store/global-store.ts +++ b/extension/js/common/platform/store/global-store.ts @@ -94,12 +94,10 @@ export class GlobalStore extends AbstractStore { } } - public static async acctEmailsRemove(acctEmail: string, openUninstallUrl = true): Promise { + public static async acctEmailsRemove(acctEmail: string): Promise { // todo: concurrency issues with another tab loaded at the same time const acctEmails = await GlobalStore.acctEmailsGet(); await GlobalStore.set({ account_emails: JSON.stringify(Value.arr.withoutVal(acctEmails, acctEmail)) }); // eslint-disable-line @typescript-eslint/naming-convention - if (openUninstallUrl) { - BrowserMsg.send.bg.updateUninstallUrl(); - } + BrowserMsg.send.bg.updateUninstallUrl(); } } diff --git a/extension/js/common/settings.ts b/extension/js/common/settings.ts index bc804f41ddd..cf0dceda2f6 100644 --- a/extension/js/common/settings.ts +++ b/extension/js/common/settings.ts @@ -87,9 +87,8 @@ export class Settings { const acctEmails = await GlobalStore.acctEmailsGet(); if (!acctEmails.includes(acctEmail)) { throw new Error(`"${acctEmail}" is not a known account_email in "${JSON.stringify(acctEmails)}"`); - } else { - await GlobalStore.acctEmailsRemove(acctEmail, false); } + await GlobalStore.acctEmailsRemove(acctEmail); const storageIndexesToRemove: AccountIndex[] = []; const filter = AbstractStore.singleScopeRawIndex(acctEmail, ''); if (!filter) { @@ -192,7 +191,6 @@ export class Settings { } } await Settings.acctStorageReset(oldAcctEmail); - await GlobalStore.acctEmailsRemove(oldAcctEmail); } public static async renderPrvCompatFixUiAndWaitTilSubmittedByUser(