Skip to content

Commit 868d2df

Browse files
authored
fix(all): [LW-8723] fix incorrect deletion of background storage (#703)
* fix(all): fix incorrect deletion of background storage * fix(all): drop `analyticsAccepted` key from local storage when deleting wallet * fix(all): add TODO comment * fix(all): fix unit tests
1 parent 77ee985 commit 868d2df

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

apps/browser-extension-wallet/src/hooks/__tests__/useWalletManager.test.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,15 +758,7 @@ describe('Testing useWalletManager hook', () => {
758758
await deleteWallet();
759759
expect(shutdownWalletMocked).toBeCalledWith(walletManagerUi);
760760
expect(clearLocalStorage).toBeCalledWith({
761-
except: [
762-
'currency',
763-
'lock',
764-
'mode',
765-
'hideBalance',
766-
'analyticsAccepted',
767-
'isForgotPasswordFlow',
768-
'multidelegationFirstVisit'
769-
]
761+
except: ['currency', 'lock', 'mode', 'hideBalance', 'isForgotPasswordFlow', 'multidelegationFirstVisit']
770762
});
771763
expect(clearBackgroundStorage).toBeCalledWith({
772764
except: ['fiatPrices', 'userId', 'usePersistentUserId', 'experimentsConfiguration']

apps/browser-extension-wallet/src/hooks/useWalletManager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ export const useWalletManager = (): UseWalletManager => {
315315
'lock',
316316
'mode',
317317
'hideBalance',
318-
'analyticsAccepted',
319318
'isForgotPasswordFlow',
320319
'multidelegationFirstVisit'
321320
];

apps/browser-extension-wallet/src/lib/scripts/background/util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ export const clearBackgroundStorage = async (options?: ClearBackgroundStorageOpt
6060
if (options.keys && options.keys.includes(key as BackgroundStorageKeys)) {
6161
delete backgroundStorage[key as BackgroundStorageKeys];
6262
}
63-
if (options.except && options.except.includes(key as BackgroundStorageKeys)) {
63+
if (options.except && !options.except.includes(key as BackgroundStorageKeys)) {
6464
delete backgroundStorage[key as BackgroundStorageKeys];
6565
}
6666
}
67+
// TODO make sure to remove other properties from webStorage (e.g. "lace-activate" seems to remain after clearing)
6768
await webStorage.local.set({ BACKGROUND_STORAGE: backgroundStorage ?? {} });
6869
};
6970

0 commit comments

Comments
 (0)