Enhance WalletService and WalletPage for improved timestamp handling and layout
- Updated WalletService to robustly handle various timestamp formats, ensuring accurate transaction date representation. - Enhanced WalletPage layout for better responsiveness, including mobile and desktop views, and improved transaction display with clearer formatting. - Adjusted transaction item styling for consistency and better user experience across different screen sizes. These changes improve the reliability and usability of transaction data presentation in the wallet module.
This commit is contained in:
parent
42b4af8fa5
commit
d2a5d90427
2 changed files with 151 additions and 50 deletions
|
|
@ -268,16 +268,35 @@ export default class WalletService extends BaseService {
|
|||
const payments = await response.json()
|
||||
|
||||
// Transform to our transaction format
|
||||
this._transactions.value = payments.map((payment: any) => ({
|
||||
id: payment.payment_hash,
|
||||
amount: Math.abs(payment.amount) / 1000,
|
||||
description: payment.memo || payment.description || 'No description',
|
||||
timestamp: payment.time ? new Date(payment.time * 1000) : new Date(),
|
||||
type: payment.amount > 0 ? 'received' : 'sent',
|
||||
status: payment.pending ? 'pending' : 'confirmed',
|
||||
fee: payment.fee ? payment.fee / 1000 : undefined,
|
||||
tag: payment.tag || (payment.extra && payment.extra.tag) || null
|
||||
})).sort((a: PaymentTransaction, b: PaymentTransaction) =>
|
||||
this._transactions.value = payments.map((payment: any) => {
|
||||
let timestamp = new Date()
|
||||
|
||||
if (payment.time) {
|
||||
// Check if it's an ISO string or Unix timestamp
|
||||
if (typeof payment.time === 'string' && payment.time.includes('T')) {
|
||||
// ISO string format (e.g., "2025-09-14T16:49:40.378877+00:00")
|
||||
timestamp = new Date(payment.time)
|
||||
} else if (typeof payment.time === 'number' || !isNaN(Number(payment.time))) {
|
||||
// Unix timestamp (seconds) - multiply by 1000 for milliseconds
|
||||
timestamp = new Date(Number(payment.time) * 1000)
|
||||
} else {
|
||||
// Try to parse as-is
|
||||
timestamp = new Date(payment.time)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
id: payment.payment_hash,
|
||||
amount: Math.abs(payment.amount) / 1000,
|
||||
description: payment.memo || payment.description || 'No description',
|
||||
timestamp: timestamp,
|
||||
type: payment.amount > 0 ? 'received' : 'sent',
|
||||
status: payment.pending ? 'pending' : 'confirmed',
|
||||
fee: payment.fee ? payment.fee / 1000 : undefined,
|
||||
tag: payment.tag || (payment.extra && payment.extra.tag) || null
|
||||
}
|
||||
}).sort((a: PaymentTransaction, b: PaymentTransaction) =>
|
||||
b.timestamp.getTime() - a.timestamp.getTime()
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue