try to fix chart udates - wip
This commit is contained in:
@@ -83,11 +83,27 @@ class LiveUpdatesPolling {
|
||||
// Handle chart updates for each timeframe
|
||||
if (data.chart_updates && this.onChartUpdate) {
|
||||
// chart_updates is an object: { '1s': {...}, '1m': {...}, ... }
|
||||
console.log('[Live Updates] Processing chart_updates:', Object.keys(data.chart_updates));
|
||||
Object.entries(data.chart_updates).forEach(([timeframe, update]) => {
|
||||
if (update) {
|
||||
console.log(`[Live Updates] Calling onChartUpdate for ${timeframe}:`, {
|
||||
symbol: update.symbol,
|
||||
timeframe: update.timeframe,
|
||||
timestamp: update.candle?.timestamp,
|
||||
is_confirmed: update.is_confirmed
|
||||
});
|
||||
this.onChartUpdate(update);
|
||||
} else {
|
||||
console.warn(`[Live Updates] Update for ${timeframe} is null/undefined`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (!data.chart_updates) {
|
||||
console.debug('[Live Updates] No chart_updates in response');
|
||||
}
|
||||
if (!this.onChartUpdate) {
|
||||
console.warn('[Live Updates] onChartUpdate callback not set!');
|
||||
}
|
||||
}
|
||||
|
||||
// Handle prediction update (single prediction for all timeframes)
|
||||
@@ -169,8 +185,33 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
window.liveUpdatesPolling.onChartUpdate = function(data) {
|
||||
// Update chart with new candle
|
||||
// data structure: { symbol, timeframe, candle: {...}, is_confirmed: true/false }
|
||||
console.log('[onChartUpdate] Callback invoked with data:', {
|
||||
symbol: data.symbol,
|
||||
timeframe: data.timeframe,
|
||||
hasCandle: !!data.candle,
|
||||
is_confirmed: data.is_confirmed,
|
||||
hasAppState: !!window.appState,
|
||||
hasChartManager: !!(window.appState && window.appState.chartManager)
|
||||
});
|
||||
|
||||
if (window.appState && window.appState.chartManager) {
|
||||
window.appState.chartManager.updateLatestCandle(data.symbol, data.timeframe, data.candle);
|
||||
// Pass the full update object so is_confirmed is available
|
||||
const candleWithFlag = {
|
||||
...data.candle,
|
||||
is_confirmed: data.is_confirmed
|
||||
};
|
||||
console.log('[onChartUpdate] Calling updateLatestCandle with:', {
|
||||
symbol: data.symbol,
|
||||
timeframe: data.timeframe,
|
||||
candle: candleWithFlag
|
||||
});
|
||||
window.appState.chartManager.updateLatestCandle(data.symbol, data.timeframe, candleWithFlag);
|
||||
} else {
|
||||
console.warn('[onChartUpdate] Chart manager not available!', {
|
||||
hasAppState: !!window.appState,
|
||||
hasChartManager: !!(window.appState && window.appState.chartManager)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user