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.
This commit is contained in:
padreug 2025-10-23 10:04:53 +02:00
parent 176501211d
commit a2108e5931

View file

@ -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) {