List transactions newest first on both chains
This commit is contained in:
@@ -174,12 +174,18 @@ struct TransactionRow: View {
|
||||
var record: TransactionRecord
|
||||
var symbol: String
|
||||
|
||||
private var formattedDate: String {
|
||||
guard let timestamp = record.timestamp else { return "Pending" }
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .short
|
||||
return formatter.string(from: timestamp)
|
||||
private var subtitle: String {
|
||||
if let timestamp = record.timestamp {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .short
|
||||
return record.confirmed ? formatter.string(from: timestamp) : "Pending confirmation"
|
||||
}
|
||||
// Monero transfers carry no timestamp; the block height is the honest label.
|
||||
if let height = record.height, height > 0 {
|
||||
return record.confirmed ? "Block \(height)" : "In the transaction pool"
|
||||
}
|
||||
return record.confirmed ? "Confirmed" : "Pending"
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -197,7 +203,7 @@ struct TransactionRow: View {
|
||||
Text(record.direction == .incoming ? "Received" : "Sent")
|
||||
.font(.system(size: 14, weight: .semibold))
|
||||
.foregroundStyle(Theme.text)
|
||||
Text(record.confirmed ? formattedDate : "Pending confirmation")
|
||||
Text(subtitle)
|
||||
.font(.system(size: 11))
|
||||
.foregroundStyle(Theme.muted)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@ struct TransactionDetailView: View {
|
||||
var chain: Chain
|
||||
var onDone: () -> Void
|
||||
|
||||
@State private var resolvedDate: Date?
|
||||
@State private var isResolvingDate = false
|
||||
|
||||
private var displayedDate: Date? { record.timestamp ?? resolvedDate }
|
||||
|
||||
private var dateFormatter: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
@@ -59,8 +64,12 @@ struct TransactionDetailView: View {
|
||||
|
||||
Card {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
if let timestamp = record.timestamp {
|
||||
DetailRow(label: "Date", value: dateFormatter.string(from: timestamp))
|
||||
if let date = displayedDate {
|
||||
DetailRow(label: "Date", value: dateFormatter.string(from: date))
|
||||
} else if isResolvingDate {
|
||||
DetailRow(label: "Date", value: "Looking up the block time…")
|
||||
} else if let height = record.height, height > 0 {
|
||||
DetailRow(label: "Block height", value: String(height))
|
||||
}
|
||||
if let fee = record.fee, !fee.isEmpty, record.direction == .outgoing {
|
||||
DetailRow(label: "Network fee", value: "\(fee) \(symbol)")
|
||||
@@ -108,6 +117,15 @@ struct TransactionDetailView: View {
|
||||
}
|
||||
}
|
||||
.preferredColorScheme(.dark)
|
||||
.task {
|
||||
guard record.timestamp == nil,
|
||||
chain == .xmr,
|
||||
let height = record.height, height > 0,
|
||||
resolvedDate == nil else { return }
|
||||
isResolvingDate = true
|
||||
resolvedDate = try? await MoneroService.shared.blockTimestamp(height: height)
|
||||
isResolvingDate = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user