handle trading view errors when changing markets

This commit is contained in:
tjs 2022-12-27 19:24:55 -05:00
parent f91b78424d
commit 3664a30462
1 changed files with 12 additions and 8 deletions

View File

@ -95,14 +95,18 @@ const TradingViewChart = () => {
useEffect(() => { useEffect(() => {
const group = mangoStore.getState().group const group = mangoStore.getState().group
if (tvWidgetRef.current && chartReady && selectedMarketName && group) { if (tvWidgetRef.current && chartReady && selectedMarketName && group) {
const market = group.getSerum3MarketByName(selectedMarketName) try {
tvWidgetRef.current.setSymbol( const market = group.getSerum3MarketByName(selectedMarketName)
market?.serumMarketExternal.toString(), tvWidgetRef.current.setSymbol(
tvWidgetRef.current.activeChart().resolution(), market?.serumMarketExternal.toString(),
() => { tvWidgetRef.current.activeChart().resolution(),
return () => {
} return
) }
)
} catch (e) {
console.warn('Trading View change symbol error: ', e)
}
} }
}, [selectedMarketName, chartReady]) }, [selectedMarketName, chartReady])