@@ -8,13 +8,13 @@ import { selectAddress } from 'app/state/wallet/selectors'
88import { AlertBox } from 'app/components/AlertBox'
99import { CircleAlert } from 'grommet-icons/es6/icons/CircleAlert'
1010import { selectSelectedNetwork } from '../../state/network/selectors'
11- import { selectAccountIsLoading } from '../../state/account/selectors'
11+ import { selectAccountAddress , selectAccountIsLoading } from '../../state/account/selectors'
1212import { Button } from 'grommet/es6/components/Button'
1313import { networkActions } from '../../state/network'
1414import { CheckBox } from 'grommet/es6/components/CheckBox'
1515import { selectThirdPartyAcknowledged } from './slice/selectors'
1616import { fiatOnrampActions } from './slice'
17- import { useState } from 'react'
17+ import { useEffect , useState } from 'react'
1818import { ShareRounded } from 'grommet-icons/es6/icons/ShareRounded'
1919import { Paragraph } from 'grommet/es6/components/Paragraph'
2020
@@ -48,6 +48,7 @@ export function FiatOnramp() {
4848 const { t } = useTranslation ( )
4949 const dispatch = useDispatch ( )
5050 const selectedNetwork = useSelector ( selectSelectedNetwork )
51+ const address = useSelector ( selectAccountAddress )
5152 const accountIsLoading = useSelector ( selectAccountIsLoading )
5253 const isAddressInWallet = useSelector ( selectIsAddressInWallet )
5354 const walletAddress = useSelector ( selectAddress )
@@ -56,6 +57,14 @@ export function FiatOnramp() {
5657 // inputs some data, then resizes: do not lose user's inputs!
5758 const [ shouldOpenTransakInNewTab ] = useState ( window . innerWidth <= 768 || window . innerHeight <= 700 )
5859
60+ // Ignore refreshing account balance. Don't destroy and re-create iframe if balance changes and account balance is loading again.
61+ const [ isInitialLoading , setInitialLoading ] = useState ( true )
62+ useEffect ( ( ) => {
63+ if ( ! ! address && ! accountIsLoading ) {
64+ setInitialLoading ( false )
65+ }
66+ } , [ address , accountIsLoading ] )
67+
5968 if ( selectedNetwork !== 'mainnet' ) {
6069 return (
6170 < Layout >
@@ -73,7 +82,7 @@ export function FiatOnramp() {
7382 </ Layout >
7483 )
7584 }
76- if ( accountIsLoading ) {
85+ if ( isInitialLoading ) {
7786 return < Layout />
7887 }
7988 if ( ! walletAddress || ! isAddressInWallet ) {
0 commit comments