From f86677fd4fd0e41620b1c475b9392f28657ed916 Mon Sep 17 00:00:00 2001 From: hasan-deriv Date: Tue, 2 Jan 2024 17:11:52 +0800 Subject: [PATCH] chore: testing live market --- .../card/live-market/index.tsx | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/features/pages/home/live-pricing-migration/card/live-market/index.tsx b/src/features/pages/home/live-pricing-migration/card/live-market/index.tsx index d6186636d50..de9f414d800 100644 --- a/src/features/pages/home/live-pricing-migration/card/live-market/index.tsx +++ b/src/features/pages/home/live-pricing-migration/card/live-market/index.tsx @@ -44,36 +44,24 @@ export const LiveMarketCard: React.FC = ({ onClickBuyButton, onClickSellButton, }) => { - // const [prevMid, setPrevMid] = useState(null) - // const [state, setState] = useState('closed') - - // useEffect(() => { - // if (prevMid !== null) { - // console.log("==>", { prevMid, mid }) - // if (mid > prevMid) { - // setState('up') - // } else if (mid < prevMid) { - // setState('down') - // } else { - // setState('remain') - // } - // } - - // // Update prevMid with the current mid - // setPrevMid(mid) - // }, [mid, prevMid]) - const prevMid = useRef(null) const prevState = prevMid.current?.dataset['state'] as MarketStatus + let chnageCount = prevMid.current?.dataset['count'] || '0' let state: MarketStatus if (mid > +prevMid?.current?.textContent) state = 'up' if (mid < +prevMid?.current?.textContent) state = 'down' - if (mid === +prevMid?.current?.textContent) state = prevState || 'up' + if (mid === +prevMid?.current?.textContent) { + state = prevState || 'up' + chnageCount = `${+chnageCount + 1}` + } else { + chnageCount = '0' + } + state = +chnageCount >= 300 ? 'closed' : state console.log('==>', state) const textClassName = - status === 'closed' ? 'text-typography-disabled' : 'text-typography-default' + state === 'closed' ? 'text-typography-disabled' : 'text-typography-default' return (