diff --git a/TalerWallet1/Model/Model+Transactions.swift b/TalerWallet1/Model/Model+Transactions.swift index 60a4ec3a..896bd275 100755 --- a/TalerWallet1/Model/Model+Transactions.swift +++ b/TalerWallet1/Model/Model+Transactions.swift @@ -147,6 +147,17 @@ struct ResumeTransaction: WalletBackendFormattedRequest { var transactionId: String } } +/// A request to retry a wallet transaction now instead of waiting for its back-off. +struct RetryTransaction: WalletBackendFormattedRequest { + struct Response: Decodable {} // no result - getting no error back means success + var operation: String { "retryTransaction" } + func args() -> Args { Args(transactionId: transactionId) } + + var transactionId: String + struct Args: Encodable { + var transactionId: String + } +} // MARK: - extension WalletModel { /// ask wallet-core for its list of transactions filtered by state @@ -198,4 +209,10 @@ extension WalletModel { logger.notice("resumeTransaction: \(transactionId, privacy: .private(mask: .hash))") _ = try await sendRequest(request, viewHandles: viewHandles) } + + nonisolated func retryTransaction(transactionId: String, viewHandles: Bool = false) async throws { + let request = RetryTransaction(transactionId: transactionId) + logger.notice("retryTransaction: \(transactionId, privacy: .private(mask: .hash))") + _ = try await sendRequest(request, viewHandles: viewHandles) + } } diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryList.swift b/TalerWallet1/Views/Transactions/TransactionSummaryList.swift index d475186d..c03c4cdf 100755 --- a/TalerWallet1/Views/Transactions/TransactionSummaryList.swift +++ b/TalerWallet1/Views/Transactions/TransactionSummaryList.swift @@ -245,6 +245,16 @@ struct TransactionSummaryList: View { @ViewBuilder func abortFailDelete(_ common: TransactionCommon) -> some View { + // wallet-core offers Retry in every waiting state, and in some of them nothing else + // (e.g. a funded withdrawal that waits for the payment service). It was decoded, + // titled and given an icon, and no view ever showed it. + if talerTX.isRetryable { + TransactionButton(transactionId: common.transactionId, + command: .retry, + warning: nil, + didExecute: $ignoreThis, + action: model.retryTransaction) + } // Retry button if talerTX.isAbortable { let warning = String(localized: "Are you sure you want to abort this transaction?") TransactionButton(transactionId: common.transactionId, @@ -340,8 +350,10 @@ struct TransactionSummaryList: View { effective: $effective, // return amount for "Pay now" possible: $paymentPossible, hasDone: hasDone) - if withActions { abortFailDelete(common) } } + // Not inside the check above: a transaction that is stuck BECAUSE the payment + // service cannot be reached is the one the user most wants to abort or delete. + if withActions { abortFailDelete(common) } }.id(viewId) // change viewId to enforce a draw update .listStyle(myListStyle.style).anyView .background(FullBackground())