Skip to content

Commit

Permalink
fix(bridge-ui): fix wrong balance updates on network switch (#15980)
Browse files Browse the repository at this point in the history
Co-authored-by: Korbinian <[email protected]>
  • Loading branch information
shak58 and KorbinianK authored Feb 22, 2024
1 parent 620a22d commit b556e00
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { getTokenAddresses } from '$libs/token/getTokenAddresses';
import { getLogger } from '$libs/util/logger';
import { uid } from '$libs/util/uid';
import { account } from '$stores/account';
import { type Account, account } from '$stores/account';
import { connectedSourceChain } from '$stores/network';
import DialogView from './DialogView.svelte';
Expand Down Expand Up @@ -174,10 +174,11 @@
if (srcChain && destChain) updateBalance($account?.address, srcChain.id, destChain.id);
};
const onAccountChange = () => {
const onAccountChange = (newAccount: Account, prevAccount?: Account) => {
const srcChain = $connectedSourceChain;
const destChain = $destNetwork;
if (srcChain && destChain) updateBalance($account?.address, srcChain.id, destChain.id);
if (destChain && srcChain && (newAccount?.chainId === prevAccount?.chainId || !newAccount || !prevAccount))
updateBalance($account?.address, srcChain.id, destChain.id);
};
$: textClass = disabled ? 'text-secondary-content' : 'font-bold ';
Expand Down

0 comments on commit b556e00

Please sign in to comment.