fix header ready check on tv chart

This commit is contained in:
tjs 2023-03-04 12:10:34 -05:00
parent 991bb6c251
commit 6fce2640a4
1 changed files with 6 additions and 3 deletions

View File

@ -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])