From 6fce2640a43340584e5952790ca03dc4d26b37b1 Mon Sep 17 00:00:00 2001 From: tjs Date: Sat, 4 Mar 2023 12:10:34 -0500 Subject: [PATCH] fix header ready check on tv chart --- components/trade/TradingViewChart.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/trade/TradingViewChart.tsx b/components/trade/TradingViewChart.tsx index 4f76f550..39eaa1eb 100644 --- a/components/trade/TradingViewChart.tsx +++ b/components/trade/TradingViewChart.tsx @@ -741,7 +741,7 @@ const TradingViewChart = () => { console.log('creating new chart') const tvWidget = new widget(widgetOptions) tvWidgetRef.current = tvWidget - tvWidgetRef.current.headerReady().then(() => { + tvWidgetRef.current.onChartReady(() => { setChartReady(true) }) } @@ -751,11 +751,14 @@ const TradingViewChart = () => { useEffect(() => { if ( chartReady && + tvWidgetRef.current && !orderLinesButtonRef.current && !stablePriceButtonRef.current ) { - createOLButton() - createStablePriceButton() + tvWidgetRef.current.headerReady().then(() => { + createOLButton() + createStablePriceButton() + }) } }, [createOLButton, chartReady, createStablePriceButton])