diff --git a/static/js/index.js b/static/js/index.js index c333238..6e4aacb 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -315,19 +315,31 @@ window.app = Vue.createApp({ }, async loadTransactions(offset = null) { try { - // Use provided offset or current pagination offset - const currentOffset = offset !== null ? offset : this.transactionPagination.offset + // Use provided offset or current pagination offset, ensure it's an integer + 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( '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 ) // Update transactions and pagination info this.transactions = response.data.entries 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_prev = response.data.has_prev } catch (error) {