diff --git a/basicswap/static/js/offerstable.js b/basicswap/static/js/offerstable.js index 66b14f8..b0ad0b7 100644 --- a/basicswap/static/js/offerstable.js +++ b/basicswap/static/js/offerstable.js @@ -1188,7 +1188,18 @@ async function fetchPricesWithApiKey(baseUrl) { } const data = await response.json(); + console.log('Received price data:', data); + if (data && !data.Error && Object.keys(data).length > 0) { + const hasValidPrices = Object.values(data).every(coin => + coin && typeof coin.usd === 'number' && !isNaN(coin.usd) + ); + + if (!hasValidPrices) { + //console.warn('Received invalid price data structure'); + return null; + } + return data; } console.log('API key fetch returned invalid data'); @@ -1247,11 +1258,11 @@ function getEmptyPriceData() { async function fetchLatestPrices() { const PRICES_CACHE_KEY = 'prices_coingecko'; - const RETRY_DELAY = 5000; + const RETRY_DELAY = 100000; const MAX_RETRIES = 3; const cachedData = CacheManager.get(PRICES_CACHE_KEY); - if (cachedData && cachedData.remainingTime > 60000) { + if (cachedData && cachedData.remainingTime > 80000) { console.log('Using cached price data (valid for next minute)'); latestPrices = cachedData.value; return cachedData.value; @@ -1480,7 +1491,7 @@ function updateProfitLoss(row, fromCoin, toCoin, fromAmount, toAmount, isOwnOffe .then(percentDiff => { if (percentDiff === null) { profitLossElement.textContent = 'N/A'; - profitLossElement.className = 'profit-loss text-lg font-bold text-gray-400'; + profitLossElement.className = 'profit-loss text-lg font-bold text-gray-300'; return; } @@ -1619,7 +1630,7 @@ async function updateOffersTable() { const PRICES_CACHE_KEY = 'prices_coingecko'; const cachedPrices = CacheManager.get(PRICES_CACHE_KEY); - if (!cachedPrices || !cachedPrices.remainingTime || cachedPrices.remainingTime < 60000) { + if (!cachedPrices || !cachedPrices.remainingTime || cachedPrices.remainingTime < 80000) { console.log('Fetching fresh price data...'); const priceData = await fetchLatestPrices(); if (priceData) { @@ -1791,7 +1802,6 @@ function createTableRow(offer, identity = null) { const fromAmount = parseFloat(amountFrom) || 0; const toAmount = parseFloat(amountTo) || 0; - // Build row content row.innerHTML = ` ${!isPublic ? createPrivateIndicator() : '