indicator refresh on detail edit

This commit is contained in:
2026-04-20 15:46:45 -04:00
parent eabc307a2a
commit 9736a3b44e

View File

@@ -781,8 +781,25 @@ export function useCustomIndicators(tvWidget: any) {
} }
) )
// ------------------------------------------------------------------
// Refresh studies when the indicator script is edited externally
// ------------------------------------------------------------------
const indicatorUpdatedHandler: MessageHandler = (message) => {
if (message.type !== 'event' || message.eventType !== 'INDICATOR_UPDATED') return
const pandasTaName: string | undefined = message.payload?.indicatorName
if (!pandasTaName) return
for (const indicator of Object.values(indicatorStore.indicators)) {
if (indicator.pandas_ta_name !== pandasTaName) continue
if (!registered.has(indicator.id)) continue
console.log('[CustomIndicators] Indicator updated, refreshing:', pandasTaName, indicator.id)
refreshCustomStudy(indicator)
}
}
wsManager.addHandler(indicatorUpdatedHandler)
// Cleanup // Cleanup
return () => { return () => {
wsManager.removeHandler(indicatorUpdatedHandler)
if (rangeWatchTimer) { clearTimeout(rangeWatchTimer); rangeWatchTimer = null } if (rangeWatchTimer) { clearTimeout(rangeWatchTimer); rangeWatchTimer = null }
for (const id of [...registered.keys()]) { for (const id of [...registered.keys()]) {
removeCustomStudy(id) removeCustomStudy(id)