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:
parent
176501211d
commit
a2108e5931
1 changed files with 8 additions and 5 deletions
|
|
@ -1013,7 +1013,7 @@ window.app = Vue.createApp({
|
||||||
paymentHash: null,
|
paymentHash: null,
|
||||||
checkWalletKey: null,
|
checkWalletKey: null,
|
||||||
pollIntervalId: 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'
|
originalCurrency: fiatCurrency || 'BTC'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -1214,7 +1214,7 @@ window.app = Vue.createApp({
|
||||||
reference: '',
|
reference: '',
|
||||||
loading: false,
|
loading: false,
|
||||||
paymentSuccess: false,
|
paymentSuccess: false,
|
||||||
exchangeRate: fiatAmount > 0 ? userBalance.balance / fiatAmount : (this.currentExchangeRate || 3571.43),
|
exchangeRate: fiatAmount > 0 ? userBalance.balance / fiatAmount : this.currentExchangeRate,
|
||||||
originalCurrency: fiatCurrency || 'BTC'
|
originalCurrency: fiatCurrency || 'BTC'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -1374,9 +1374,12 @@ window.app = Vue.createApp({
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading exchange rate:', error)
|
console.error('Error loading exchange rate:', error)
|
||||||
// Fallback to a reasonable default if API fails
|
this.currentExchangeRate = null
|
||||||
this.currentExchangeRate = 3571.43
|
this.$q.notify({
|
||||||
console.log('Using fallback exchange rate:', this.currentExchangeRate)
|
type: 'warning',
|
||||||
|
message: 'Failed to load exchange rate. Fiat currency conversions may not be available.',
|
||||||
|
timeout: 5000
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formatSats(amount) {
|
formatSats(amount) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue