From f8103a71253759318732960cc1ce5f4babc94594 Mon Sep 17 00:00:00 2001 From: Alex Ruzenhack Date: Tue, 23 Apr 2024 13:47:03 +0100 Subject: [PATCH] refactor: clean tx history and metadata first on wallet start --- src/sagas/wallet.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sagas/wallet.js b/src/sagas/wallet.js index 21f068c7e..05c20b0f0 100644 --- a/src/sagas/wallet.js +++ b/src/sagas/wallet.js @@ -124,7 +124,7 @@ export function* isWalletServiceEnabled() { let walletServiceEnabled = yield call(checkForFeatureFlag, WALLET_SERVICE_FEATURE_TOGGLE); - // At this point the networkSettings already have been set by startWallet. + // At this point, the networkSettings have already been set by startWallet. const networkSettings = yield select(getNetworkSettings); if (walletServiceEnabled && isEmpty(networkSettings.walletServiceUrl)) { // In case of an empty value for walletServiceUrl, it means the user @@ -143,6 +143,13 @@ export function* startWallet(action) { pin, } = action.payload; + // clean memory storage and metadata before starting the wallet. + // This should be cleaned when stopping the wallet, + // but the wallet may be closed unexpectedly + const storage = STORE.getStorage(); + yield call([storage.store, storage.store.cleanMetadata]); // clean metadata on memory + yield call([storage, storage.cleanStorage], true); // clean transaction history + // As this is a core setting for the wallet, it should be loaded first. // Network settings either from store or redux state let networkSettings; @@ -172,13 +179,6 @@ export function* startWallet(action) { yield put(setUseWalletService(useWalletService)); yield put(setAvailablePushNotification(usePushNotification)); - // clean storage and metadata before starting the wallet - // this should be cleaned when stopping the wallet, - // but the wallet may be closed unexpectedly - const storage = STORE.getStorage(); - yield storage.store.cleanMetadata(); - yield storage.cleanStorage(true); - // This is a work-around so we can dispatch actions from inside callbacks. let dispatch; yield put((_dispatch) => {