From cbde2897eddd4296be4d9f74e180f43529620c5a Mon Sep 17 00:00:00 2001 From: 3mp8r3 <3mp8r3@gmail.com> Date: Fri, 28 Jan 2022 09:41:09 +0800 Subject: [PATCH 1/2] Fix landing page on mobile --- src/pages/LandingPage/LandingPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/LandingPage/LandingPage.tsx b/src/pages/LandingPage/LandingPage.tsx index 72b0f4c6b..4b3ac6b61 100755 --- a/src/pages/LandingPage/LandingPage.tsx +++ b/src/pages/LandingPage/LandingPage.tsx @@ -554,7 +554,7 @@ const LandingPage: React.FC = () => { }, [ethPrice, updateEthPrice, updateGlobalData]); return ( -
+
{openStakeModal && ( Date: Sat, 29 Jan 2022 03:43:28 +0800 Subject: [PATCH 2/2] remove unnecessary hooks, update function name to fetch global data and update function to get dQUICK APY. --- src/pages/LandingPage/LandingPage.tsx | 42 +++++++++------------------ 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/src/pages/LandingPage/LandingPage.tsx b/src/pages/LandingPage/LandingPage.tsx index 4b3ac6b61..7e5ee99b4 100755 --- a/src/pages/LandingPage/LandingPage.tsx +++ b/src/pages/LandingPage/LandingPage.tsx @@ -44,11 +44,7 @@ import { getDaysCurrentYear, returnTokenFromKey, } from 'utils'; -import { - useEthPrice, - useGlobalData, - useWalletModalToggle, -} from 'state/application/hooks'; +import { useGlobalData, useWalletModalToggle } from 'state/application/hooks'; import { GlobalConst } from 'constants/index'; import { useLairInfo, useTotalRewardsDistributed } from 'state/stake/hooks'; @@ -513,7 +509,6 @@ const LandingPage: React.FC = () => { ]; const history = useHistory(); - const { ethPrice, updateEthPrice } = useEthPrice(); const { globalData, updateGlobalData } = useGlobalData(); const lairInfo = useLairInfo(); @@ -525,33 +520,22 @@ const LandingPage: React.FC = () => { Number(lairInfo?.quickPrice)); const dQUICKAPY = useMemo(() => { - return APR - ? ( - (Math.pow(1 + APR / daysCurrentYear, daysCurrentYear) - 1) * - 100 - ).toFixed(4) - : 0; + if (!APR) return; + return (Math.pow(1 + APR / daysCurrentYear, daysCurrentYear) - 1) * 100; }, [APR, daysCurrentYear]); const totalRewardsUSD = useTotalRewardsDistributed(); useEffect(() => { - async function checkEthPrice() { - if (!ethPrice.price) { - const [newPrice, oneDayPrice, priceChange] = await getEthPrice(); - updateEthPrice({ - price: newPrice, - oneDayPrice, - ethPriceChange: priceChange, - }); - const globalData = await getGlobalData(newPrice, oneDayPrice); - if (globalData) { - updateGlobalData({ data: globalData }); - } + async function fetchGlobalData() { + const [newPrice, oneDayPrice] = await getEthPrice(); + const newGlobalData = await getGlobalData(newPrice, oneDayPrice); + if (newGlobalData) { + updateGlobalData({ data: newGlobalData }); } } - checkEthPrice(); - }, [ethPrice, updateEthPrice, updateGlobalData]); + fetchGlobalData(); + }, [updateGlobalData]); return (
@@ -612,7 +596,7 @@ const LandingPage: React.FC = () => { - {globalData?.oneDayTxns ? ( + {globalData ? ( {Number(globalData.oneDayTxns).toLocaleString()} @@ -696,9 +680,9 @@ const LandingPage: React.FC = () => { - {globalData ? ( + {dQUICKAPY ? ( - {Number(dQUICKAPY).toLocaleString()}% + {dQUICKAPY.toLocaleString()}% ) : (