fix balance calculation vue glitch.
This commit is contained in:
parent
211ac0391b
commit
88b8826bfd
2 changed files with 18 additions and 17 deletions
|
|
@ -175,22 +175,20 @@ new Vue({
|
||||||
disclaimerDialog: {
|
disclaimerDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
location: window.location
|
location: window.location
|
||||||
}
|
},
|
||||||
|
balance: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
formattedBalance: function () {
|
||||||
|
return LNbits.utils.formatSat(this.balance || this.g.wallet.sat)
|
||||||
|
},
|
||||||
filteredPayments: function () {
|
filteredPayments: function () {
|
||||||
var q = this.paymentsTable.filter
|
var q = this.paymentsTable.filter
|
||||||
if (!q || q === '') return this.payments
|
if (!q || q === '') return this.payments
|
||||||
|
|
||||||
return LNbits.utils.search(this.payments, q)
|
return LNbits.utils.search(this.payments, q)
|
||||||
},
|
},
|
||||||
balance: function () {
|
|
||||||
return this.apiBalance || this.g.wallet.sat
|
|
||||||
},
|
|
||||||
fbalance: function () {
|
|
||||||
return LNbits.utils.formatSat(this.balance)
|
|
||||||
},
|
|
||||||
canPay: function () {
|
canPay: function () {
|
||||||
if (!this.send.invoice) return false
|
if (!this.send.invoice) return false
|
||||||
return this.send.invoice.sat <= this.balance
|
return this.send.invoice.sat <= this.balance
|
||||||
|
|
@ -382,6 +380,16 @@ new Vue({
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
fetchBalance: function () {
|
||||||
|
var self = this
|
||||||
|
LNbits.api.getWallet(self.g.wallet).then(function (response) {
|
||||||
|
self.balance = Math.round(response.data.balance / 1000)
|
||||||
|
EventHub.$emit('update-wallet-balance', [
|
||||||
|
self.g.wallet.id,
|
||||||
|
self.balance
|
||||||
|
])
|
||||||
|
})
|
||||||
|
},
|
||||||
checkPendingPayments: function () {
|
checkPendingPayments: function () {
|
||||||
var dismissMsg = this.$q.notify({
|
var dismissMsg = this.$q.notify({
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
|
|
@ -399,18 +407,11 @@ new Vue({
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
payments: function () {
|
payments: function () {
|
||||||
var self = this
|
this.fetchBalance()
|
||||||
|
|
||||||
LNbits.api.getWallet(self.g.wallet).then(function (response) {
|
|
||||||
self.apiBalance = Math.round(response.data.balance / 1000)
|
|
||||||
EventHub.$emit('update-wallet-balance', [
|
|
||||||
self.g.wallet.id,
|
|
||||||
self.balance
|
|
||||||
])
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
|
this.fetchBalance()
|
||||||
this.fetchPayments()
|
this.fetchPayments()
|
||||||
setTimeout(this.checkPendingPayments(), 1200)
|
setTimeout(this.checkPendingPayments(), 1200)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<h3 class="q-my-none">
|
<h3 class="q-my-none">
|
||||||
<strong>{% raw %}{{ fbalance }}{% endraw %}</strong> sat
|
<strong>{% raw %}{{ formattedBalance }}{% endraw %}</strong> sat
|
||||||
</h3>
|
</h3>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<div class="row q-pb-md q-px-md q-col-gutter-md">
|
<div class="row q-pb-md q-px-md q-col-gutter-md">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue