diff --git a/src/ui/views/Dashboard/index.tsx b/src/ui/views/Dashboard/index.tsx index eb5a4ffa..8cbc413c 100644 --- a/src/ui/views/Dashboard/index.tsx +++ b/src/ui/views/Dashboard/index.tsx @@ -49,45 +49,53 @@ const Dashboard = ({ value, setValue }) => { setValue(index); }; - const fetchAll = useCallback(async () => { - setLoading(true); - //todo fix cadence loading - await wallet.getCadenceScripts(); - const [network, userDomain] = await Promise.all([ - wallet.getNetwork(), - wallet.fetchUserDomain(), - ]); - const isChild = await wallet.getActiveWallet(); - - if (isChild === 'evm') { - setIsEvm(true); - } - const env: string = process.env.NODE_ENV!; - const firebaseConfig = getFirbaseConfig(); - console.log(process.env.NODE_ENV); - // const firebaseProductionConfig = prodConig; - - const app = initializeApp(firebaseConfig, env); - const remoteConfig = getRemoteConfig(app); - console.log('remoteConfig ', app); - fetchAndActivate(remoteConfig) - .then((res) => { - console.log('res ', remoteConfig); - - console.log('Remote Config values fetched and activated'); - }) - .catch((error) => { - console.error('Error fetching remote config:', error); - }); - - setNetwork(network); - setDomain(userDomain); - setLoading(false); - }, [wallet]); - useEffect(() => { - fetchAll(); - }, [fetchAll, wallet]); + console.log('useEffect - fetchAll'); + let isMounted = true; + + const fetchAll = async () => { + //todo fix cadence loading + await wallet.getCadenceScripts(); + const [network, userDomain] = await Promise.all([ + wallet.getNetwork(), + wallet.fetchUserDomain(), + ]); + const isChild = await wallet.getActiveWallet(); + + if (isChild === 'evm') { + setIsEvm(true); + } + const env: string = process.env.NODE_ENV!; + const firebaseConfig = getFirbaseConfig(); + + const app = initializeApp(firebaseConfig, env); + const remoteConfig = getRemoteConfig(app); + console.log('remoteConfig ', app); + fetchAndActivate(remoteConfig) + .then((res) => { + console.log('res ', remoteConfig); + + console.log('Remote Config values fetched and activated'); + }) + .catch((error) => { + console.error('Error fetching remote config:', error); + }); + + return { network, userDomain }; + }; + + fetchAll().then(({ network, userDomain }) => { + if (isMounted) { + setNetwork(network); + setDomain(userDomain); + setLoading(false); + } + }); + + return () => { + isMounted = false; + }; + }, [wallet]); return (
diff --git a/src/ui/views/Wallet/index.tsx b/src/ui/views/Wallet/index.tsx index d47c396c..a094b7eb 100644 --- a/src/ui/views/Wallet/index.tsx +++ b/src/ui/views/Wallet/index.tsx @@ -127,7 +127,7 @@ const WalletTab = ({ network }) => { const pollTimer = setInterval(async () => { const nowTime = new Date().getTime(); const data = await func(); - if (data.length > 2 || nowTime - startTime >= endTime) { + if ((data && data.length > 2) || nowTime - startTime >= endTime) { if (pollTimer) { clearInterval(pollTimer); }