From a1cd8386da111dcc68bc4c508f23557f6db6dd89 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Tue, 16 Jan 2024 16:18:36 -0500 Subject: [PATCH] fix: incorrect symbol being shown for the current page --- libs/trading-view/src/lib/trading-view.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/trading-view/src/lib/trading-view.tsx b/libs/trading-view/src/lib/trading-view.tsx index 12ed2e1c1..70023c152 100644 --- a/libs/trading-view/src/lib/trading-view.tsx +++ b/libs/trading-view/src/lib/trading-view.tsx @@ -135,6 +135,14 @@ export const TradingView = ({ if (state !== undefined) { // Load stored state widgetRef.current.load(state); + + // Whatever was the last active chart will be loaded, so reset the current symbol for + // the market loaded on the page + widgetRef.current.setSymbol( + marketId, + interval as TVResolutionString, + noop + ); } else { // No stored state, likely the first time using the TV chart, // show the volume study by default @@ -160,6 +168,7 @@ export const TradingView = ({ return () => { if (!widgetRef.current) return; widgetRef.current.remove(); + widgetRef.current = undefined; }; }, []);