Fix: Prevent indicators from being deleted during TF switch
- Remove window.renderIndicatorList() call from renderTA() - This was triggering initIndicatorPanel during each TF switch - Added logging to removeIndicatorById to track unexpected deletions - Removed indicator configuration UI from TA panel (sidebar handles this now)
This commit is contained in:
@ -499,7 +499,7 @@ async loadTA() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderTA() {
|
renderTA() {
|
||||||
if (!this.taData || this.taData.error) {
|
if (!this.taData || this.taData.error) {
|
||||||
document.getElementById('taContent').innerHTML = `<div class="ta-error">${this.taData?.error || 'No data available'}</div>`;
|
document.getElementById('taContent').innerHTML = `<div class="ta-error">${this.taData?.error || 'No data available'}</div>`;
|
||||||
return;
|
return;
|
||||||
@ -542,23 +542,7 @@ async loadTA() {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ta-section">
|
|
||||||
<div class="ta-section-title">Indicators</div>
|
|
||||||
<div id="indicatorList" class="indicator-list"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ta-section" id="indicatorConfigPanel">
|
|
||||||
<div class="ta-section-title">Configuration</div>
|
|
||||||
<div id="configForm" style="margin-top: 8px;"></div>
|
|
||||||
<div style="display: flex; gap: 8px; margin-top: 12px;" id="configButtons">
|
|
||||||
<button class="ta-btn" onclick="applyIndicatorConfig()" style="flex: 1; font-size: 11px; background: var(--tv-blue); color: white; border: none;">Apply</button>
|
|
||||||
<button class="ta-btn" onclick="removeIndicator()" style="flex: 1; font-size: 11px; border-color: var(--tv-red); color: var(--tv-red);">Remove</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
window.renderIndicatorList?.();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadStats() {
|
async loadStats() {
|
||||||
|
|||||||
@ -496,16 +496,27 @@ window.clearAllIndicators = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeIndicatorById(id) {
|
function removeIndicatorById(id) {
|
||||||
|
console.log(`[removeIndicatorById] Attempting to remove indicator: ${id}`);
|
||||||
|
console.log('Call stack:', console.trace());
|
||||||
|
|
||||||
const idx = activeIndicators.findIndex(a => a.id === id);
|
const idx = activeIndicators.findIndex(a => a.id === id);
|
||||||
if (idx < 0) return;
|
if (idx < 0) {
|
||||||
|
console.warn(`[removeIndicatorById] Indicator ${id} not found in array`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[removeIndicatorById] Removing indicator at index ${idx}`);
|
||||||
|
|
||||||
activeIndicators[idx].series?.forEach(s => {
|
activeIndicators[idx].series?.forEach(s => {
|
||||||
try { window.dashboard?.chart?.removeSeries(s); } catch(e) {}
|
try { window.dashboard?.chart?.removeSeries(s); } catch(e) {}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remove the specific indicator, don't clear the whole array
|
||||||
activeIndicators.splice(idx, 1);
|
activeIndicators.splice(idx, 1);
|
||||||
|
|
||||||
if (configuringId === id) {
|
console.log(`[removeIndicatorById] After removal, array now has ${activeIndicators.length} indicators`);
|
||||||
|
|
||||||
|
if (configuringId === id) {
|
||||||
configuringId = null;
|
configuringId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,6 +805,12 @@ export function drawIndicatorsOnChart() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (activeIndicators.length === 0) {
|
||||||
|
console.error('⚠️ drawIndicatorsOnChart: activeIndicators is EMPTY!');
|
||||||
|
console.error('⚠️ This means indicators were lost during TF switch!');
|
||||||
|
console.trace('Call stack showing where we are:');
|
||||||
|
}
|
||||||
|
|
||||||
const currentInterval = window.dashboard.currentInterval;
|
const currentInterval = window.dashboard.currentInterval;
|
||||||
const candles = window.dashboard.allData.get(currentInterval);
|
const candles = window.dashboard.allData.get(currentInterval);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user