Skip to content

Commit

Permalink
fix: Intermittent tradingview crash on setup
Browse files Browse the repository at this point in the history
  • Loading branch information
memoyil committed Feb 25, 2025
1 parent 6a6acdb commit f54c8c6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
4 changes: 2 additions & 2 deletions apps/web/src/__tests__/utils/apr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ describe('getFarmApr', () => {
BIG_TEN,
new BigNumber(1),
new BigNumber(100000),
'0x0ed7e52944161450477ee417de9cd3a859b14fd0',
'0x0eD7e52944161450477ee417DE9Cd3a859b14fD0',
40,
)
expect(cakeRewardsApr).toEqual(4204800)
expect(lpRewardsApr).toEqual(lpAprs['0x0ed7e52944161450477ee417de9cd3a859b14fd0'])
expect(lpRewardsApr).toEqual(lpAprs['0x0eD7e52944161450477ee417DE9Cd3a859b14fD0'])
})
})
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

0 comments on commit f54c8c6

Please sign in to comment.