taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit ae7a063131582f96b70d6eb6e6dd4436581c767e
parent f4599bbb89c9caefbb3c9271663014f53b87dc56
Author: Marc Stibane <marc@taler.net>
Date:   Fri, 19 Jan 2024 08:38:16 +0100

show minor in tx details

Diffstat:
MTalerWallet1/Backend/WalletCore.swift | 16+++++++++++-----
MTalerWallet1/Views/Transactions/TransactionDetailView.swift | 16+++++-----------
2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift @@ -193,7 +193,9 @@ extension WalletCore { if components.count >= 3 { // txn:$txtype:$uid if let type = TransactionType(rawValue: components[1]) { guard type != .refresh else { return } - switch decoded.newTxState.major { + let newMajor = decoded.newTxState.major + let newMinor = decoded.newTxState.minor + switch newMajor { case .done: logger.info("Done: \(decoded.transactionId, privacy: .private(mask: .hash))") if type.isWithdrawal { @@ -204,7 +206,7 @@ extension WalletCore { postNotification(.TransactionDone, userInfo: [TRANSACTIONTRANSITION: decoded]) return case .aborting: - if let newMinor = decoded.newTxState.minor { + if let newMinor { if newMinor == .refreshExpired { logger.warning("RefreshExpired: \(decoded.transactionId, privacy: .private(mask: .hash))") Controller.shared.playSound(0) @@ -220,7 +222,7 @@ extension WalletCore { postNotification(.TransactionExpired, userInfo: [TRANSACTIONTRANSITION: decoded]) return case .pending: - if let newMinor = decoded.newTxState.minor { + if let newMinor { if newMinor == .ready { logger.log("PendingReady: \(decoded.transactionId, privacy: .private(mask: .hash))") postNotification(.PendingReady, userInfo: [TRANSACTIONTRANSITION: decoded]) @@ -237,11 +239,15 @@ extension WalletCore { } logger.log("Pending:\(newMinor.rawValue, privacy: .public) \(decoded.transactionId, privacy: .private(mask: .hash))") } else { - logger.log("Pending: \(decoded.transactionId, privacy: .private(mask: .hash))") + logger.log("Pending: \(decoded.transactionId, privacy: .private(mask: .hash))") } postNotification(.TransactionStateTransition, userInfo: [TRANSACTIONTRANSITION: decoded]) default: - logger.warning("Unknow transition: \(decoded.transactionId, privacy: .private(mask: .hash))") + if let newMinor { + logger.warning("\(newMajor.rawValue, privacy: .public):\(newMinor.rawValue, privacy: .public) \(decoded.transactionId, privacy: .private(mask: .hash))") + } else { + logger.warning("\(newMajor.rawValue, privacy: .public): \(decoded.transactionId, privacy: .private(mask: .hash))") + } postNotification(.TransactionStateTransition, userInfo: [TRANSACTIONTRANSITION: decoded]) } // switch } // type diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift b/TalerWallet1/Views/Transactions/TransactionDetailView.swift @@ -45,15 +45,6 @@ struct TransactionDetailView: View { @State var transaction: Transaction = Transaction(dummyCurrency: DEMOCURRENCY) @State var viewId = UUID() - func accessibilityDate(_ date: Date?) -> String? { - if let date { - let formatted = date.formatted(date: .long, time: .shortened) -// print(formatted) - return formatted - } - return nil - } - func loadTransaction() async { do { let reloadedTransaction = try await reloadAction(transactionId) @@ -107,7 +98,7 @@ struct TransactionDetailView: View { let pending = transaction.isPending let locale = TalerDater.shared.locale let (dateString, date) = TalerDater.dateString(from: common.timestamp) - let accessibilityDate = accessibilityDate(date) ?? dateString + let accessibilityDate = TalerDater.accessibilityDate(date) ?? dateString let navTitle2 = transaction.localizedType VStack { List { @@ -127,13 +118,16 @@ struct TransactionDetailView: View { .foregroundColor(colorSchemeContrast == .increased ? .primary : .secondary) .listRowSeparator(.hidden) VStack(alignment: .trailing) { + let majorState = common.txState.major.localizedState let minorState = common.txState.minor?.localizedState ?? nil + let state = transaction.isPending ? minorState ?? majorState + : majorState HStack { Text(verbatim: "|") // only reason for this leading-aligned text is to get a nice full length listRowSeparator .accessibilityHidden(true) .foregroundColor(Color.clear) Spacer() - Text("Status: \(minorState ?? common.txState.major.localizedState)") + Text("Status: \(state)") .multilineTextAlignment(.trailing) } } .listRowSeparator(.automatic)