From 9736a3b44e6712410113c3a3351c338c69c87ee1 Mon Sep 17 00:00:00 2001 From: Tim Olson Date: Mon, 20 Apr 2026 15:46:45 -0400 Subject: [PATCH] indicator refresh on detail edit --- web/src/composables/useCustomIndicators.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/web/src/composables/useCustomIndicators.ts b/web/src/composables/useCustomIndicators.ts index 96cf41b5..50dc66e7 100644 --- a/web/src/composables/useCustomIndicators.ts +++ b/web/src/composables/useCustomIndicators.ts @@ -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 return () => { + wsManager.removeHandler(indicatorUpdatedHandler) if (rangeWatchTimer) { clearTimeout(rangeWatchTimer); rangeWatchTimer = null } for (const id of [...registered.keys()]) { removeCustomStudy(id)