From 30226c37afa4034ec20fcb93419a8e2aa132561c Mon Sep 17 00:00:00 2001 From: gerlofvanek Date: Fri, 29 Aug 2025 21:21:50 +0200 Subject: [PATCH] Fix BTC chart loads even if BTC is not enabled --- basicswap/static/js/pricechart.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/basicswap/static/js/pricechart.js b/basicswap/static/js/pricechart.js index 6ab1b5c..96a0555 100644 --- a/basicswap/static/js/pricechart.js +++ b/basicswap/static/js/pricechart.js @@ -1136,15 +1136,32 @@ const app = { if (chartModule.chart) { window.config.currentResolution = 'day'; - await chartModule.updateChart('BTC'); - app.updateResolutionButtons('BTC'); + + let defaultCoin = null; + if (window.config.coins && window.config.coins.length > 0) { + for (const coin of window.config.coins) { + const container = document.getElementById(`${coin.symbol.toLowerCase()}-container`); + if (container) { + defaultCoin = coin.symbol; + break; + } + } + } + + if (!defaultCoin) { + defaultCoin = 'BTC'; + } + + await chartModule.updateChart(defaultCoin); + app.updateResolutionButtons(defaultCoin); const chartTitle = document.getElementById('chart-title'); if (chartTitle) { - chartTitle.textContent = 'Price Chart (BTC)'; + chartTitle.textContent = `Price Chart (${defaultCoin})`; } + + ui.setActiveContainer(`${defaultCoin.toLowerCase()}-container`); } - ui.setActiveContainer('btc-container'); app.setupEventListeners(); app.initAutoRefresh();