feat: instrument analysis
This commit is contained in:
@@ -1205,8 +1205,8 @@ const PERIODS = [
|
||||
{ key: '5y', label: '5Y' },
|
||||
]
|
||||
|
||||
export default function InstrumentDashboard({ instrumentIdProp }: { instrumentIdProp?: string } = {}) {
|
||||
const { id: paramId = 'EURUSD' } = useParams<{ id: string }>()
|
||||
export default function InstrumentDashboard({ instrumentIdProp, isVisible }: { instrumentIdProp?: string; isVisible?: boolean } = {}) {
|
||||
const { id: paramId = localStorage.getItem('last_instrument') || 'EURUSD' } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const [period, setPeriod] = useState('1y')
|
||||
const [chartStyle, setChartStyle] = useState<'candles' | 'line'>('candles')
|
||||
@@ -1237,6 +1237,14 @@ export default function InstrumentDashboard({ instrumentIdProp }: { instrumentId
|
||||
api.get('/causal-lab/templates').then(r => setTemplates(r.data)).catch(() => {})
|
||||
}, [])
|
||||
|
||||
// Silent refresh when the tab becomes visible again (e.g. after analysis updated from MarketEvents)
|
||||
const mountedRef = useRef(false)
|
||||
useEffect(() => {
|
||||
if (!mountedRef.current) { mountedRef.current = true; return }
|
||||
if (isVisible) fetchSnapshotSilent()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isVisible])
|
||||
|
||||
const fetchSnapshot = useCallback(() => {
|
||||
setLoading(true)
|
||||
api.get(`/instruments/${instrumentId}/snapshot?period=${period}`)
|
||||
|
||||
Reference in New Issue
Block a user