From b09fe9ebb1bb2d0e1d0f60931615685cca0e4011 Mon Sep 17 00:00:00 2001 From: moo-onthelawn <70078372+moo-onthelawn@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:19:37 -0500 Subject: [PATCH] fix bug (#304) --- src/hooks/tradingView/useChartMarketAndResolution.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hooks/tradingView/useChartMarketAndResolution.ts b/src/hooks/tradingView/useChartMarketAndResolution.ts index 9343b2d..a6b5451 100644 --- a/src/hooks/tradingView/useChartMarketAndResolution.ts +++ b/src/hooks/tradingView/useChartMarketAndResolution.ts @@ -27,19 +27,26 @@ export const useChartMarketAndResolution = ({ const dispatch = useDispatch(); const currentMarketId: string = useSelector(getCurrentMarketId) || DEFAULT_MARKETID; + const selectedResolution: string = useSelector(getSelectedResolutionForMarket(currentMarketId)) || DEFAULT_RESOLUTION; const chart = isWidgetReady ? tvWidget?.chart() : undefined; const chartResolution = chart?.resolution?.(); + /** + * @description Hook to handle changing markets - intentionally should avoid triggering on change of resolutions. + */ useEffect(() => { if (currentMarketId && isWidgetReady) { const resolution = savedResolution || selectedResolution; tvWidget?.setSymbol(currentMarketId, resolution as ResolutionString, () => {}); } - }, [currentMarketId, isWidgetReady, savedResolution, selectedResolution]); + }, [currentMarketId, isWidgetReady]); + /** + * @description Hook to handle changing chart resolution + */ useEffect(() => { if (chartResolution) { if (chartResolution !== selectedResolution) {