fix: keep the selected accountId if its present int the url (#588)
This commit is contained in:
parent
8435ed3498
commit
5afead47f2
@ -5,6 +5,7 @@ import AccountCreateFirst from 'components/Account/AccountCreateFirst'
|
|||||||
import { CircularProgress } from 'components/CircularProgress'
|
import { CircularProgress } from 'components/CircularProgress'
|
||||||
import FullOverlayContent from 'components/FullOverlayContent'
|
import FullOverlayContent from 'components/FullOverlayContent'
|
||||||
import WalletBridges from 'components/Wallet/WalletBridges'
|
import WalletBridges from 'components/Wallet/WalletBridges'
|
||||||
|
import useAccountId from 'hooks/useAccountId'
|
||||||
import useAccountIds from 'hooks/useAccountIds'
|
import useAccountIds from 'hooks/useAccountIds'
|
||||||
import useWalletBalances from 'hooks/useWalletBalances'
|
import useWalletBalances from 'hooks/useWalletBalances'
|
||||||
import useStore from 'store'
|
import useStore from 'store'
|
||||||
@ -28,6 +29,7 @@ function FetchLoading() {
|
|||||||
function Content() {
|
function Content() {
|
||||||
const address = useStore((s) => s.address)
|
const address = useStore((s) => s.address)
|
||||||
const { address: urlAddress } = useParams()
|
const { address: urlAddress } = useParams()
|
||||||
|
const urlAccountId = useAccountId()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { pathname } = useLocation()
|
const { pathname } = useLocation()
|
||||||
const { data: accountIds, isLoading: isLoadingAccounts } = useAccountIds(address || '')
|
const { data: accountIds, isLoading: isLoadingAccounts } = useAccountIds(address || '')
|
||||||
@ -52,7 +54,7 @@ function Content() {
|
|||||||
accountIds.length !== 0 &&
|
accountIds.length !== 0 &&
|
||||||
BN(baseBalance).isGreaterThanOrEqualTo(defaultFee.amount[0].amount)
|
BN(baseBalance).isGreaterThanOrEqualTo(defaultFee.amount[0].amount)
|
||||||
) {
|
) {
|
||||||
navigate(getRoute(page, address, accountIds[0]))
|
navigate(getRoute(page, address, urlAccountId ?? accountIds[0]))
|
||||||
useStore.setState({ balances: walletBalances, focusComponent: null })
|
useStore.setState({ balances: walletBalances, focusComponent: null })
|
||||||
}
|
}
|
||||||
}, [accountIds, baseBalance, navigate, pathname, address, walletBalances, urlAddress])
|
}, [accountIds, baseBalance, navigate, pathname, address, walletBalances, urlAddress])
|
||||||
|
Loading…
Reference in New Issue
Block a user