fix: at least one charge must be active in order to fetch balance

This commit is contained in:
Vlad Stan
2022-07-12 10:44:42 +03:00
parent f9fd071315
commit 809d03d3db
2 changed files with 18 additions and 11 deletions

View File

@@ -49,7 +49,6 @@ class Charges(BaseModel):
def time_elapsed(self): def time_elapsed(self):
return self.time_left < 0 return self.time_left < 0
@property @property
def paid(self): def paid(self):
if self.balance >= self.amount: if self.balance >= self.amount:

View File

@@ -128,6 +128,7 @@
<q-td key="timeLeft" :props="props" :class=""> <q-td key="timeLeft" :props="props" :class="">
<div>{{props.row.timeLeft}}</div> <div>{{props.row.timeLeft}}</div>
<q-linear-progress <q-linear-progress
v-if="props.row.timeLeft"
:value="props.row.progress" :value="props.row.progress"
color="secondary" color="secondary"
> >
@@ -580,16 +581,23 @@
this.createCharge(wallet, data) this.createCharge(wallet, data)
}, },
refreshActiveChargesBalance: async function () { refreshActiveChargesBalance: async function () {
const activeLinkIds = this.chargeLinks try {
.filter(c => !c.paid && !c.time_elapsed && !c.hasStaleBalance) const activeLinkIds = this.chargeLinks
.map(c => c.id) .filter(c => !c.paid && !c.time_elapsed && !c.hasStaleBalance)
.join(',') .map(c => c.id)
await LNbits.api.request( .join(',')
'GET', if (activeLinkIds) {
'/satspay/api/v1/charges/balance/' + activeLinkIds, await LNbits.api.request(
'filla' 'GET',
) '/satspay/api/v1/charges/balance/' + activeLinkIds,
await this.getCharges() 'filla'
)
}
} catch (error) {
LNbits.utils.notifyApiError(error)
} finally {
await this.getCharges()
}
}, },
refreshBalance: async function (charge) { refreshBalance: async function (charge) {
try { try {