From 876eb4f20b61d4e08db480a3393e5bc3a57fe97f Mon Sep 17 00:00:00 2001 From: padreug Date: Sun, 14 Sep 2025 23:23:23 +0200 Subject: [PATCH] Update WalletService and WalletPage to handle timestamps more robustly - Modified WalletService to set a default timestamp when payment time is not provided, ensuring consistent date handling. - Enhanced WalletPage to validate timestamps before formatting, preventing potential errors and improving user experience by displaying a placeholder for invalid timestamps. These changes improve the reliability of transaction data presentation in the wallet module. --- src/modules/wallet/services/WalletService.ts | 2 +- src/modules/wallet/views/WalletPage.vue | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/modules/wallet/services/WalletService.ts b/src/modules/wallet/services/WalletService.ts index bdb5334..fa99e76 100644 --- a/src/modules/wallet/services/WalletService.ts +++ b/src/modules/wallet/services/WalletService.ts @@ -271,7 +271,7 @@ export default class WalletService extends BaseService { id: payment.payment_hash, amount: Math.abs(payment.amount), description: payment.memo || payment.description || 'No description', - timestamp: new Date(payment.time * 1000), + timestamp: payment.time ? new Date(payment.time * 1000) : new Date(), type: payment.amount > 0 ? 'received' : 'sent', status: payment.pending ? 'pending' : 'confirmed', fee: payment.fee diff --git a/src/modules/wallet/views/WalletPage.vue b/src/modules/wallet/views/WalletPage.vue index 808d691..f0e0871 100644 --- a/src/modules/wallet/views/WalletPage.vue +++ b/src/modules/wallet/views/WalletPage.vue @@ -38,15 +38,20 @@ const totalBalance = computed(() => { // Get transactions grouped by date const groupedTransactions = computed(() => { const groups: Record = {} - + transactions.value.forEach((tx: any) => { - const dateKey = format(tx.timestamp, 'MMMM d, yyyy') + // Ensure timestamp is valid before formatting + const timestamp = tx.timestamp instanceof Date && !isNaN(tx.timestamp.getTime()) + ? tx.timestamp + : new Date() + + const dateKey = format(timestamp, 'MMMM d, yyyy') if (!groups[dateKey]) { groups[dateKey] = [] } groups[dateKey].push(tx) }) - + return groups }) @@ -189,7 +194,11 @@ onMounted(() => {

{{ tx.description }}

- {{ format(tx.timestamp, 'HH:mm') }} + {{ + tx.timestamp instanceof Date && !isNaN(tx.timestamp.getTime()) + ? format(tx.timestamp, 'HH:mm') + : '--:--' + }} {{ tx.status }}