mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2026-02-23 15:14:19 +01:00
Only optimistically get price when balance non-zero
This commit is contained in:
committed by
Paul Miller
parent
414671acce
commit
8555f3a1f3
@@ -182,17 +182,25 @@ export const Provider: ParentComponent = (props) => {
|
||||
// Get balance + price optimistically
|
||||
const balance = await mutinyWallet.get_balance();
|
||||
let price;
|
||||
try {
|
||||
if (state.fiat.value === "BTC") {
|
||||
price = 1;
|
||||
} else {
|
||||
price = await mutinyWallet.get_bitcoin_price(
|
||||
state.fiat.value.toLowerCase() || "usd"
|
||||
);
|
||||
// only get price if balance is non-zero
|
||||
if (
|
||||
balance.confirmed > 0 ||
|
||||
balance.unconfirmed > 0 ||
|
||||
balance.lightning > 0 ||
|
||||
balance.force_close > 0
|
||||
) {
|
||||
try {
|
||||
if (state.fiat.value === "BTC") {
|
||||
price = 1;
|
||||
} else {
|
||||
price = await mutinyWallet.get_bitcoin_price(
|
||||
state.fiat.value.toLowerCase() || "usd"
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
price = 0;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
price = 0;
|
||||
}
|
||||
|
||||
setState({
|
||||
|
||||
Reference in New Issue
Block a user