From a2108e5931a0786c271ffd0d725d439cdea4b046 Mon Sep 17 00:00:00 2001 From: padreug Date: Thu, 23 Oct 2025 10:04:53 +0200 Subject: [PATCH] Improves exchange rate handling and error display. Updates the exchange rate calculation to rely solely on the current exchange rate when a valid fiat amount is not available. Removes the hardcoded default exchange rate fallback and instead displays a user-friendly warning message when fetching the exchange rate fails. This informs the user that fiat currency conversions might be unavailable. --- static/js/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index a2878c8..12bcb7b 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -1013,7 +1013,7 @@ window.app = Vue.createApp({ paymentHash: null, checkWalletKey: null, pollIntervalId: null, - exchangeRate: fiatAmount > 0 ? Math.abs(userBalance.balance) / fiatAmount : (this.currentExchangeRate || 3571.43), // Calculate rate from actual amounts or use current rate + exchangeRate: fiatAmount > 0 ? Math.abs(userBalance.balance) / fiatAmount : this.currentExchangeRate, // Calculate rate from actual amounts or use current rate originalCurrency: fiatCurrency || 'BTC' } }, @@ -1214,7 +1214,7 @@ window.app = Vue.createApp({ reference: '', loading: false, paymentSuccess: false, - exchangeRate: fiatAmount > 0 ? userBalance.balance / fiatAmount : (this.currentExchangeRate || 3571.43), + exchangeRate: fiatAmount > 0 ? userBalance.balance / fiatAmount : this.currentExchangeRate, originalCurrency: fiatCurrency || 'BTC' } }, @@ -1374,9 +1374,12 @@ window.app = Vue.createApp({ } } catch (error) { console.error('Error loading exchange rate:', error) - // Fallback to a reasonable default if API fails - this.currentExchangeRate = 3571.43 - console.log('Using fallback exchange rate:', this.currentExchangeRate) + this.currentExchangeRate = null + this.$q.notify({ + type: 'warning', + message: 'Failed to load exchange rate. Fiat currency conversions may not be available.', + timeout: 5000 + }) } }, formatSats(amount) {