fix: topup wallet was showing NaN (#2504)

* fix: topup wallet was showing NaN
This commit is contained in:
dni ⚡ 2024-05-16 15:31:24 +02:00 committed by GitHub
parent 7a6c3646fb
commit 35bb3cc94b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@ -145,7 +145,7 @@ window.LNbits = {
)
},
updateBalance: function (credit, wallet_id) {
return LNbits.api.request('PUT', '/users/api/v1/topup/', null, {
return LNbits.api.request('PUT', '/users/api/v1/topup', null, {
amount: credit,
id: wallet_id
})

View File

@ -702,7 +702,14 @@ Vue.component('lnbits-update-balance', {
LNbits.api
.updateBalance(credit, this.wallet_id)
.then(res => {
this.callback({value: res, wallet_id: this.wallet_id})
if (res.data.status !== 'Success') {
throw new Error(res.data)
}
this.callback({
success: true,
credit: parseInt(credit),
wallet_id: this.wallet_id
})
})
.then(_ => {
credit = parseInt(credit)

View File

@ -351,12 +351,14 @@ new Vue({
console.log('export users')
},
topupCallback(res) {
this.wallets.forEach(wallet => {
if (res.wallet_id === wallet.id) {
wallet.balance_msat += res.value * 1000
}
})
this.fetchUsers()
if (res.success) {
this.wallets.forEach(wallet => {
if (res.wallet_id === wallet.id) {
wallet.balance_msat += res.credit * 1000
}
})
this.fetchUsers()
}
},
topupWallet() {
LNbits.api

View File

@ -535,7 +535,9 @@ new Vue({
.catch(e => console.error(e))
},
updateBalanceCallback: function (res) {
this.balance += res.value
if (res.success && wallet.id === res.wallet_id) {
this.balance += res.credit
}
},
pasteToTextArea: function () {
this.$refs.textArea.focus() // Set cursor to textarea