From bacdd99b0c805667b5e432f9c5824daab2fb8a5b Mon Sep 17 00:00:00 2001 From: Tina Zheng Date: Thu, 15 Aug 2024 17:49:53 -0400 Subject: [PATCH] update marks when there are new fills --- src/hooks/tradingView/useBuySellMarks.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hooks/tradingView/useBuySellMarks.ts b/src/hooks/tradingView/useBuySellMarks.ts index 46ba179e3..58d81e0c2 100644 --- a/src/hooks/tradingView/useBuySellMarks.ts +++ b/src/hooks/tradingView/useBuySellMarks.ts @@ -2,6 +2,10 @@ import { Dispatch, SetStateAction, useEffect } from 'react'; import { TvWidget } from '@/constants/tvchart'; +import { getMarketFills } from '@/state/accountSelectors'; +import { useAppSelector } from '@/state/appTypes'; +import { getCurrentMarketId } from '@/state/perpetualsSelectors'; + /** * @description Hook to handle marks for historic buys and sells on the TV chart */ @@ -18,8 +22,12 @@ export function useBuySellMarks({ tvWidget: TvWidget | null; isChartReady: boolean; }) { + const marketId = useAppSelector(getCurrentMarketId); + const fills = useAppSelector(getMarketFills); + const currentMarketFills = marketId ? fills[marketId] : undefined; + useEffect(() => { - // Initialize onClick for orderbook candles toggle + // Initialize onClick for Buys/Sells toggle if (isChartReady && buySellMarksToggle) { buySellMarksToggle.onclick = () => setBuySellMarksToggleOn((prev) => !prev); } @@ -42,6 +50,6 @@ export function useBuySellMarks({ }); }); }, - [buySellMarksToggleOn, buySellMarksToggle, tvWidget, isChartReady] + [buySellMarksToggleOn, buySellMarksToggle, tvWidget, isChartReady, currentMarketFills] ); }