indicator refresh on detail edit
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user