Ensures transaction offset is a valid number
Addresses an issue where the transaction offset could be non-numeric, causing errors in pagination. Adds validation and parsing to ensure the offset is always an integer, falling back to 0 if necessary. Also ensures that limit is parsed into an Int.
This commit is contained in:
parent
69b8f6e2d3
commit
093cecbff2
1 changed files with 16 additions and 4 deletions
|
|
@ -315,19 +315,31 @@ window.app = Vue.createApp({
|
||||||
},
|
},
|
||||||
async loadTransactions(offset = null) {
|
async loadTransactions(offset = null) {
|
||||||
try {
|
try {
|
||||||
// Use provided offset or current pagination offset
|
// Use provided offset or current pagination offset, ensure it's an integer
|
||||||
const currentOffset = offset !== null ? offset : this.transactionPagination.offset
|
let currentOffset = 0
|
||||||
|
if (offset !== null && offset !== undefined) {
|
||||||
|
currentOffset = parseInt(offset)
|
||||||
|
} else if (this.transactionPagination && this.transactionPagination.offset !== null && this.transactionPagination.offset !== undefined) {
|
||||||
|
currentOffset = parseInt(this.transactionPagination.offset)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Final safety check - ensure it's a valid number
|
||||||
|
if (isNaN(currentOffset)) {
|
||||||
|
currentOffset = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const limit = parseInt(this.transactionPagination.limit) || 20
|
||||||
|
|
||||||
const response = await LNbits.api.request(
|
const response = await LNbits.api.request(
|
||||||
'GET',
|
'GET',
|
||||||
`/castle/api/v1/entries/user?limit=${this.transactionPagination.limit}&offset=${currentOffset}`,
|
`/castle/api/v1/entries/user?limit=${limit}&offset=${currentOffset}`,
|
||||||
this.g.user.wallets[0].inkey
|
this.g.user.wallets[0].inkey
|
||||||
)
|
)
|
||||||
|
|
||||||
// Update transactions and pagination info
|
// Update transactions and pagination info
|
||||||
this.transactions = response.data.entries
|
this.transactions = response.data.entries
|
||||||
this.transactionPagination.total = response.data.total
|
this.transactionPagination.total = response.data.total
|
||||||
this.transactionPagination.offset = response.data.offset
|
this.transactionPagination.offset = parseInt(response.data.offset) || 0
|
||||||
this.transactionPagination.has_next = response.data.has_next
|
this.transactionPagination.has_next = response.data.has_next
|
||||||
this.transactionPagination.has_prev = response.data.has_prev
|
this.transactionPagination.has_prev = response.data.has_prev
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue