bugfixes; research subproc; higher sandbox limits
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onBeforeUnmount, watch } from 'vue'
|
||||
import { ref, onMounted, onBeforeUnmount, watch, type WatchStopHandle } from 'vue'
|
||||
import Card from 'primevue/card'
|
||||
import { createTradingViewDatafeed } from '../composables/useTradingViewDatafeed'
|
||||
import { useTradingViewShapes } from '../composables/useTradingViewShapes'
|
||||
@@ -11,10 +11,11 @@ import type { IChartingLibraryWidget } from '../types/tradingview'
|
||||
import { intervalToSeconds } from '../utils'
|
||||
import { wsManager } from '../composables/useWebSocket'
|
||||
|
||||
// Convert seconds to TradingView interval string
|
||||
// Convert seconds to TradingView interval string.
|
||||
// TradingView uses plain minute numbers ("60", "240") for intraday,
|
||||
// and "1D", "2D" etc for daily. Never use "H" suffix — it's not in supported_resolutions.
|
||||
function secondsToInterval(seconds: number): string {
|
||||
if (seconds % 86400 === 0) return `${seconds / 86400}D`
|
||||
if (seconds % 3600 === 0) return `${seconds / 3600}H`
|
||||
return `${seconds / 60}` // plain number = minutes
|
||||
}
|
||||
|
||||
@@ -27,9 +28,23 @@ let shapeCleanup: (() => void) | null = null // Cleanup function for shape sync
|
||||
let indicatorCleanup: (() => void) | null = null // Cleanup function for indicator sync
|
||||
let customIndicatorCleanup: (() => void) | null = null // Cleanup for custom TV studies
|
||||
let chartInitialized = false // Guard against double-init on reconnect
|
||||
let symbolWatcher: WatchStopHandle | null = null
|
||||
|
||||
const maybeInitChart = () => {
|
||||
if (chartInitialized || !chartContainer.value) return
|
||||
if (!chartStore.symbol) {
|
||||
// Defer until backend provides a symbol
|
||||
if (!symbolWatcher) {
|
||||
symbolWatcher = watch(() => chartStore.symbol, (sym) => {
|
||||
if (sym) {
|
||||
symbolWatcher?.()
|
||||
symbolWatcher = null
|
||||
maybeInitChart()
|
||||
}
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
chartInitialized = true
|
||||
initChart()
|
||||
}
|
||||
@@ -205,6 +220,10 @@ function setupStoreWatchers() {
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (symbolWatcher) {
|
||||
symbolWatcher()
|
||||
symbolWatcher = null
|
||||
}
|
||||
// Cleanup shape synchronization
|
||||
if (shapeCleanup) {
|
||||
shapeCleanup()
|
||||
|
||||
Reference in New Issue
Block a user