Skip to content

Commit

Permalink
Merge pull request #2145 from cardano-foundation/bugfix/MET-935-messa…
Browse files Browse the repository at this point in the history
…ge-btc-price-update

fix: MET-935-message-price-btc-update
  • Loading branch information
sato-thuyetnguyen authored Oct 6, 2023
2 parents 6135231 + 3d2e8df commit f190d2a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/Home/Statistic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import moment from "moment";
import { useSelector } from "react-redux";
import { Link as LinkDom } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { useEffect, useRef } from "react";
import { useEffect, useRef, useState } from "react";

import useFetch from "src/commons/hooks/useFetch";
import { useScreen } from "src/commons/hooks/useScreen";
Expand Down Expand Up @@ -111,6 +111,11 @@ const HomeStatistic = () => {
market_cap: 0
});
const priceBTC = useRef<number>(0);
const [usdLatestUpdated, setUsdLastUpdated] = useState<string>("");

useEffect(() => {
setUsdLastUpdated(usdMarket?.last_updated || "");
}, [usdMarket?.last_updated]);

useEffect(() => {
if (Number(usdMarket?.market_cap) !== Number(marketcap.current.market_cap)) {
Expand All @@ -125,10 +130,7 @@ const HomeStatistic = () => {
useEffect(() => {
if (Number(btcMarket?.current_price) !== priceBTC.current) {
priceBTC.current = Number(btcMarket?.current_price);
marketcap.current = {
...marketcap.current,
last_updated: btcMarket?.last_updated || ""
};
setUsdLastUpdated(btcMarket?.last_updated || "");
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [btcMarket?.current_price, marketcap.current]);
Expand Down Expand Up @@ -176,7 +178,7 @@ const HomeStatistic = () => {
</Content>
<Content>
<TimeDuration data-testid="last-update-ada-price">
<FormNowMessage time={usdMarket.last_updated} />
<FormNowMessage time={usdLatestUpdated} />
</TimeDuration>
</Content>
</WrapCardContent>
Expand Down

0 comments on commit f190d2a

Please sign in to comment.