Added paginated fetching to withdraw link table (#41)
Some checks failed
/ release (push) Has been cancelled
/ pullrequest (push) Has been cancelled

This commit is contained in:
Julian 2024-07-19 07:22:46 +02:00 committed by GitHub
commit 00064f65d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 50 additions and 23 deletions

View file

@ -59,7 +59,9 @@ new Vue({
{name: 'max', align: 'right', label: 'Max (sat)', field: 'max_fsat'}
],
pagination: {
rowsPerPage: 10
page: 1,
rowsPerPage: 10,
rowsNumber: 0
}
},
nfcTagWriting: false,
@ -97,19 +99,30 @@ new Vue({
}
},
methods: {
getWithdrawLinks: function () {
getWithdrawLinks: function (props) {
if (props) {
this.withdrawLinksTable.pagination = props.pagination
}
let pagination = this.withdrawLinksTable.pagination
const query = {
limit: pagination.rowsPerPage,
offset: (pagination.page - 1) * pagination.rowsPerPage
}
var self = this
LNbits.api
.request(
'GET',
'/withdraw/api/v1/links?all_wallets=true',
`/withdraw/api/v1/links?all_wallets=true&limit=${query.limit}&offset=${query.offset}`,
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.withdrawLinks = response.data.map(function (obj) {
self.withdrawLinks = response.data.data.map(function (obj) {
return mapWithdrawLink(obj)
})
self.withdrawLinksTable.pagination.rowsNumber = response.data.total
})
.catch(function (error) {
clearInterval(self.checker)
@ -309,11 +322,8 @@ new Vue({
},
created: function () {
if (this.g.user.wallets.length) {
var getWithdrawLinks = this.getWithdrawLinks
getWithdrawLinks()
this.checker = setInterval(function () {
getWithdrawLinks()
}, 300000)
this.getWithdrawLinks()
this.checker = setInterval(this.getWithdrawLinks, 300000)
}
}
})