Skip to content

Commit

Permalink
fix: try catch error load active chart
Browse files Browse the repository at this point in the history
  • Loading branch information
trungbach committed Feb 23, 2024
1 parent bd14f31 commit 4cfeebc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/oraidex-common-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-common-ui",
"version": "1.0.9",
"version": "1.0.10",
"files": [
"dist/"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,19 @@ export default function TVChartContainer({
const script = document.createElement("script");
script.async = true;
script.src = libraryUrl;
script.onload = () => {
script.onload = async () => {
tvWidgetRef.current = new window.TradingView.widget(widgetOptions as any as ChartingLibraryWidgetOptions);

const checkChartReady = async () => {
try {
if (tvWidgetRef.current.activeChart()) return;
} catch {
await new Promise((r) => setTimeout(r, 1000));
await checkChartReady();
}
};
await checkChartReady();

tvWidgetRef.current.onChartReady(function () {
setChartReady(true);
tvWidgetRef.current!.applyOverrides({
Expand Down

0 comments on commit 4cfeebc

Please sign in to comment.