From 093cecbff270cde77a6e814697d007cb04e2b3dd Mon Sep 17 00:00:00 2001 From: padreug Date: Sun, 9 Nov 2025 00:06:07 +0100 Subject: [PATCH] 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. --- static/js/index.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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) {