commit 477a0e4b2bedc5b639821577fd1c355ded5ba237
parent 318f15a049718853df3d0ddc917caab95137f9a8
Author: Marc Stibane <marc@taler.net>
Date: Wed, 13 Dec 2023 22:51:52 +0100
withdraw-exchange
Diffstat:
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/TalerWallet1/Views/Exchange/ManualWithdraw.swift b/TalerWallet1/Views/Exchange/ManualWithdraw.swift
@@ -6,7 +6,8 @@ import SwiftUI
import taler_swift
import SymLog
-// Will be called by the user tapping "Withdraw Coins" in the exchange list
+// Will be called by either the user tapping "Withdraw Coins" in the exchange list
+// or from WithdrawExchangeV after a withdraw-exchange QR was scanned
struct ManualWithdraw: View {
private let symLog = SymLogV(0)
let stack: CallStack
@@ -93,20 +94,24 @@ struct ManualWithdraw: View {
LoadingView(url: nil, message: exchangeBaseUrl.trimURL())
}
} .task(id: amountToTransfer.value) { // re-run this whenever amountToTransfer changes
- symLog.log("getExchangeByUrl(\(exchangeBaseUrl))")
- do {
+ symLog.log("getExchangeByUrl(\(exchangeBaseUrl))")
+ if exchange == nil || exchange?.tosStatus != .accepted {
if let exc = await model.getExchangeByUrl(url: exchangeBaseUrl) {
exchange = exc
- if !amountToTransfer.isZero {
- let details = try await model.loadWithdrawalDetailsForAmountM(exchangeBaseUrl,
- amount: amountToTransfer)
- withdrawalAmountDetails = details
+ } else {
+ // TODO: Error "Can't get Exchange Info"
+ }
+ }
+ if !amountToTransfer.isZero {
+ do {
+ let details = try await model.loadWithdrawalDetailsForAmountM(exchangeBaseUrl,
+ amount: amountToTransfer)
+ withdrawalAmountDetails = details
// agePicker.setAges(ages: withdrawalAmountDetails?.ageRestrictionOptions)
- }
+ } catch { // TODO: error
+ symLog.log(error.localizedDescription)
+ withdrawalAmountDetails = nil
}
- } catch { // TODO: error
- symLog.log(error.localizedDescription)
- withdrawalAmountDetails = nil
}
}
}