commit 69060647395ffbaa39d996d7f5ab5236fb6708e6
parent 710fcf5188d5dffbbc00971dba845fc5e12af280
Author: Marc Stibane <marc@taler.net>
Date: Mon, 24 Aug 2026 14:30:35 +0200
AI: when, hint are optional in wallet-core
Diffstat:
2 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/TalerWallet1/Model/Transaction.swift b/TalerWallet1/Model/Transaction.swift
@@ -590,8 +590,8 @@ enum RefreshReason: String, Decodable {
}
struct RefreshError: Decodable {
var code: Int
- var when: Timestamp
- var hint: String
+ var when: Timestamp?
+ var hint: String?
var stack: String?
var numErrors: Int? // how many coins had errors
var errors: [TalerErrorDetail]? // 1..max(5, numErrors)
diff --git a/TalerWallet1/Views/Transactions/TransactionTypeDetail.swift b/TalerWallet1/Views/Transactions/TransactionTypeDetail.swift
@@ -56,6 +56,19 @@ struct TransactionTypeDetail: View {
return nil
}
+ func errorHintStack(_ hint: String?, _ stack: String?) -> String? {
+ if let hint, !hint.isEmpty {
+ if let stack, !stack.isEmpty {
+ return hint + "\n" + stack
+ }
+ return hint
+ }
+ if let stack, !stack.isEmpty {
+ return stack
+ }
+ return nil
+ }
+
var body: some View {
#if PRINT_CHANGES
let _ = Self._printChanges()
@@ -197,22 +210,24 @@ struct TransactionTypeDetail: View {
if let error = details.error {
HStack {
VStack(alignment: .leading) {
- Text(error.hint)
- .talerFont(.headline)
- .foregroundColor(errorColor)
- .listRowSeparator(.hidden)
- if let stack = error.stack {
+ if let hint = error.hint, !hint.isEmpty {
+ Text(hint)
+ .talerFont(.headline)
+ .foregroundColor(errorColor)
+ .listRowSeparator(.hidden)
+ }
+ if let stack = error.stack, !stack.isEmpty {
Text(stack)
.talerFont(.body)
.foregroundColor(errorColor)
.listRowSeparator(.hidden)
}
}
- let stackStr = error.stack ?? EMPTYSTRING
- let errorStr = error.hint + "\n" + stackStr
- CopyButton(errorStr, vertical: true)
- .accessibilityLabel(Text("Copy the error", comment: "a11y"))
- .disabled(false)
+ if let errorStr = errorHintStack(error.hint, error.stack) {
+ CopyButton(errorStr, vertical: true)
+ .accessibilityLabel(Text("Copy the error", comment: "a11y"))
+ .disabled(false)
+ }
}
}
}