From b814d79b20110fe874d62484c57f016c9a85e59a Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 20 Jun 2022 12:54:01 -0300 Subject: [PATCH 1/2] [FIX] rates needed for update wallets --- src/store/wallet/effects/init/init.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/store/wallet/effects/init/init.ts b/src/store/wallet/effects/init/init.ts index 660617e9c..9c3949787 100644 --- a/src/store/wallet/effects/init/init.ts +++ b/src/store/wallet/effects/init/init.ts @@ -11,14 +11,14 @@ export const startWalletStoreInit = const {WALLET, APP} = getState(); const defaultAltCurrencyIsoCode = APP.defaultAltCurrency.isoCode; - await dispatch(startGetTokenOptions()); + // both needed for startUpdateAllKeyAndWalletStatus + await dispatch(startGetTokenOptions()); // get more recent 1inch tokens list + await dispatch(startGetRates({init: true})); // populate rates and alternative currency list if (Object.keys(WALLET.keys).length) { dispatch(startUpdateAllKeyAndWalletStatus({})); } - await dispatch(startGetRates({init: true})); // populate rates and alternative currency list - dispatch(getPriceHistory(defaultAltCurrencyIsoCode)); dispatch(updatePortfolioBalance()); dispatch(WalletActions.successWalletStoreInit()); From 06eed80d2076d2d24eb16c73a0504a75d1fb0769 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Tue, 21 Jun 2022 14:52:24 -0300 Subject: [PATCH 2/2] [FEAT] update portfolio balance after updating keys --- src/navigation/tabs/home/HomeRoot.tsx | 5 ++++- src/store/wallet/effects/init/init.ts | 4 +--- src/store/wallet/effects/status/status.ts | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/navigation/tabs/home/HomeRoot.tsx b/src/navigation/tabs/home/HomeRoot.tsx index 8b19480c2..e2057a411 100644 --- a/src/navigation/tabs/home/HomeRoot.tsx +++ b/src/navigation/tabs/home/HomeRoot.tsx @@ -127,10 +127,13 @@ const HomeRoot = () => { }, [brazeQuickLinks]); const showPortfolioValue = useAppSelector(({APP}) => APP.showPortfolioValue); + const appIsLoading = useAppSelector(({APP}) => APP.appIsLoading); useEffect(() => { return navigation.addListener('focus', () => { - dispatch(updatePortfolioBalance()); + if (!appIsLoading) { + dispatch(updatePortfolioBalance()); + } // portfolio balance is updated in app init }); }, [dispatch, navigation]); diff --git a/src/store/wallet/effects/init/init.ts b/src/store/wallet/effects/init/init.ts index 9c3949787..0a16c3b76 100644 --- a/src/store/wallet/effects/init/init.ts +++ b/src/store/wallet/effects/init/init.ts @@ -3,7 +3,6 @@ import {WalletActions} from '../../index'; import {getPriceHistory, startGetRates} from '../rates/rates'; import {startGetTokenOptions} from '../currencies/currencies'; import {startUpdateAllKeyAndWalletStatus} from '../status/status'; -import {updatePortfolioBalance} from '../../wallet.actions'; export const startWalletStoreInit = (): Effect> => async (dispatch, getState: () => RootState) => { @@ -12,7 +11,7 @@ export const startWalletStoreInit = const defaultAltCurrencyIsoCode = APP.defaultAltCurrency.isoCode; // both needed for startUpdateAllKeyAndWalletStatus - await dispatch(startGetTokenOptions()); // get more recent 1inch tokens list + await dispatch(startGetTokenOptions()); // needed for getRates. Get more recent 1inch tokens list await dispatch(startGetRates({init: true})); // populate rates and alternative currency list if (Object.keys(WALLET.keys).length) { @@ -20,7 +19,6 @@ export const startWalletStoreInit = } dispatch(getPriceHistory(defaultAltCurrencyIsoCode)); - dispatch(updatePortfolioBalance()); dispatch(WalletActions.successWalletStoreInit()); } catch (e) { console.error(e); diff --git a/src/store/wallet/effects/status/status.ts b/src/store/wallet/effects/status/status.ts index e698e3057..52192a8e0 100644 --- a/src/store/wallet/effects/status/status.ts +++ b/src/store/wallet/effects/status/status.ts @@ -377,6 +377,7 @@ export const startUpdateAllKeyAndWalletStatus = dispatch(startUpdateAllWalletStatusForKey({key, force})); }), ); + dispatch(updatePortfolioBalance()); // update portfolio balance after updating all keys balances dispatch(successUpdateAllKeysAndStatus()); resolve(); } catch (err) {