Skip to content

Commit

Permalink
chore: when changing the address, always fetch the config.
Browse files Browse the repository at this point in the history
  • Loading branch information
slient-coder committed Jan 11, 2024
1 parent 1b940a9 commit 6caea87
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/ui/state/accounts/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AppState } from '..';
import { useAppDispatch, useAppSelector } from '../hooks';
import { useCurrentKeyring } from '../keyrings/hooks';
import { keyringsActions } from '../keyrings/reducer';
import { settingsActions } from '../settings/reducer';
import { accountActions } from './reducer';

export function useAccountsState(): AppState['accounts'] {
Expand All @@ -26,8 +27,15 @@ export function useAccounts() {
export function useAccountBalance() {
const accountsState = useAccountsState();
const currentAccount = useCurrentAccount();
return accountsState.balanceMap[currentAccount.address]
|| { amount: '0', expired: true, confirm_btc_amount: '0', pending_btc_amount: '0', inscription_amount: '0' };
return (
accountsState.balanceMap[currentAccount.address] || {
amount: '0',
expired: true,
confirm_btc_amount: '0',
pending_btc_amount: '0',
inscription_amount: '0'
}
);
}

export function useAddressSummary() {
Expand Down Expand Up @@ -223,5 +231,9 @@ export function useReloadAccounts() {

dispatch(accountActions.expireBalance());
dispatch(accountActions.expireInscriptions());

wallet.getWalletConfig().then((data) => {
dispatch(settingsActions.updateSettings({ walletConfig: data }));
});
}, [dispatch, wallet]);
}

0 comments on commit 6caea87

Please sign in to comment.