Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Intermittent tradingview crash on setup #11253

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions apps/web/src/components/TradingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,34 @@ const initializeTradingView = (TradingViewObj: any, theme: DefaultTheme, localeC
} catch (e) {
// noop
}
/* eslint-disable new-cap */
/* eslint-disable no-new */
// @ts-ignore
return new TradingViewObj.widget({
// Advanced Chart Widget uses the legacy embedding scheme,
// an id property should be specified in the settings object
id: opts.container_id,
autosize: true,
height: '100%',
symbol: 'BINANCE:BNBBUSD',
interval: '5',
timezone,
theme: theme.isDark ? 'dark' : 'light',
style: '1',
locale: localeCode,
toolbar_bg: '#f1f3f6',
enable_publishing: false,
allow_symbol_change: true,
hide_side_toolbar: false,
enabled_features: ['header_fullscreen_button'],
...opts,
})

try {
/* eslint-disable new-cap */
/* eslint-disable no-new */
// @ts-ignore
return new TradingViewObj.widget({
// Advanced Chart Widget uses the legacy embedding scheme,
// an id property should be specified in the settings object
id: opts.container_id,
autosize: true,
height: '100%',
symbol: 'BINANCE:BNBBUSD',
interval: '5',
timezone,
theme: theme.isDark ? 'dark' : 'light',
style: '1',
locale: localeCode,
toolbar_bg: '#f1f3f6',
enable_publishing: false,
allow_symbol_change: true,
hide_side_toolbar: false,
enabled_features: ['header_fullscreen_button'],
...opts,
})
} catch (e) {
console.error('Failed to initialize TradingView widget:', e)
return undefined
}
}

interface TradingViewProps {
Expand Down
Loading