gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ios] 102/204: task viewDidLoad


From: gnunet
Subject: [taler-taler-ios] 102/204: task viewDidLoad
Date: Thu, 05 Dec 2024 23:51:10 +0100

This is an automated email from the git hooks/post-receive script.

marc-stibane pushed a commit to branch master
in repository taler-ios.

commit e68280f0b189aac2a5edcedf8654561caddb9155
Author: Marc Stibane <marc@taler.net>
AuthorDate: Thu Nov 7 23:30:52 2024 +0100

    task viewDidLoad
---
 .../Views/Actions/Banking/DepositAmountV.swift     | 39 ++++++-----
 .../Views/Actions/Banking/ManualWithdraw.swift     | 38 +++++++---
 .../Views/Actions/Banking/ManualWithdrawDone.swift | 20 +++---
 .../Views/Actions/Peer2peer/SendAmountV.swift      | 38 +++++-----
 .../Views/Sheets/P2P_Sheets/P2pAcceptDone.swift    | 24 ++++---
 .../Sheets/P2P_Sheets/P2pReceiveURIView.swift      | 22 +++---
 .../Views/Sheets/Payment/PayTemplateV.swift        | 81 ++++++++++++----------
 .../Views/Sheets/Payment/PaymentDone.swift         | 19 ++---
 .../Views/Sheets/Payment/PaymentView.swift         | 38 +++++-----
 .../Views/Sheets/Refund/RefundURIView.swift        | 16 +++--
 .../WithdrawAcceptDone.swift                       | 29 +++++---
 TalerWallet1/Views/Sheets/WithdrawExchangeV.swift  | 48 +++++++------
 .../Views/Transactions/ManualDetailsV.swift        | 12 ++--
 13 files changed, 242 insertions(+), 182 deletions(-)

diff --git a/TalerWallet1/Views/Actions/Banking/DepositAmountV.swift 
b/TalerWallet1/Views/Actions/Banking/DepositAmountV.swift
index 7e46cd6..4263762 100644
--- a/TalerWallet1/Views/Actions/Banking/DepositAmountV.swift
+++ b/TalerWallet1/Views/Actions/Banking/DepositAmountV.swift
@@ -25,6 +25,26 @@ struct DepositAmountV: View {
     @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING)   
 // Update currency when used
     @State private var amountAvailable = Amount.zero(currency: EMPTYSTRING)    
 // GetMaxPeerPushAmount
 
+    private func viewDidLoad() async {
+        let balances = controller.balances
+        if let selectedBalance {
+            if selectedBalance.available.isZero {
+                // find another balance
+                balance = Balance.firstNonZero(balances)
+            } else {
+                balance = selectedBalance
+            }
+        } else {
+            balance = Balance.firstNonZero(balances)
+        }
+        if let balance {
+            balanceIndex = balances.firstIndex(of: balance) ?? 0
+        } else {
+            balanceIndex = 0
+            balance = (balances.count > 0) ? balances[0] : nil
+        }
+    }
+
     var body: some View {
 #if PRINT_CHANGES
         let _ = Self._printChanges()
@@ -63,24 +83,7 @@ struct DepositAmountV: View {
             .onDisappear {
                 symLog.log("❗️ \(navTitle) onDisappear")
             }
-            .task {
-                if let selectedBalance {
-                    if selectedBalance.available.isZero {
-                        // find another balance
-                        balance = Balance.firstNonZero(controller.balances)
-                    } else {
-                        balance = selectedBalance
-                    }
-                } else {
-                    balance = Balance.firstNonZero(controller.balances)
-                }
-                if let balance {
-                    balanceIndex = controller.balances.firstIndex(of: balance) 
?? 0
-                } else {
-                    balanceIndex = 0
-                    balance = (count > 0) ? controller.balances[0] : nil
-                }
-            }
+            .task { await viewDidLoad() }
             .task(id: balanceIndex + (1000 * controller.currencyTicker)) {
                 symLog.log("❗️ task \(balanceIndex)")
                 if let balance {
diff --git a/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift 
b/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift
index b0cb5cf..7310636 100644
--- a/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift
+++ b/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift
@@ -25,6 +25,18 @@ struct ManualWithdraw: View {
     @State private var currencyInfo: CurrencyInfo = CurrencyInfo.zero(UNKNOWN)
     @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING)   
 // Update currency when used
 
+    private func viewDidLoad() async {
+        if let selectedBalance {
+            balance = selectedBalance
+            balanceIndex = controller.balances.firstIndex(of: selectedBalance) 
?? 0
+        } else {
+            balanceIndex = 0
+            balance = (controller.balances.count > 0) ? controller.balances[0] 
: nil
+        }
+        if let balance {
+            currencyInfo = controller.info(for: balance.scopeInfo, 
controller.currencyTicker)
+        }
+    }
     func navTitle(_ currency: String, _ condition: Bool = false) -> String {
         condition ? String(localized: "NavTitle_Withdraw_Currency)",
                         defaultValue: "Withdraw \(currency)",
@@ -75,15 +87,7 @@ struct ManualWithdraw: View {
             .onDisappear {
                 symLog.log("❗️ \(navTitle) onDisappear")
             }
-            .task {
-                if let selectedBalance {
-                    balance = selectedBalance
-                    balanceIndex = controller.balances.firstIndex(of: 
selectedBalance) ?? 0
-                } else {
-                    balanceIndex = 0
-                    balance = (count > 0) ? controller.balances[0] : nil
-                }
-            }
+            .task { await viewDidLoad() }
             .task(id: balanceIndex + (1000 * controller.currencyTicker)) {
                 // runs whenever the user changes the exchange via 
ScopePicker, or on new currencyInfo
                 symLog.log("❗️ task \(balanceIndex)")
@@ -156,6 +160,19 @@ struct ManualWithdrawContent: View {
         return nil
     } // computeFee
 
+    private func viewDidLoad2() async {
+        // neues scope wenn balance geändert wird?
+        let details = try? await 
model.getWithdrawalDetailsForAmountM(amountToTransfer, baseUrl: nil, scope: 
scope,
+                                                         viewHandles: true)
+        if let details {
+            detailsForAmount = details
+            if exchange == nil || exchange?.tosStatus != .accepted {
+                symLog.log("getExchangeByUrl(\(details.exchangeBaseUrl))")
+                exchange = try? await model.getExchangeByUrl(url: 
details.exchangeBaseUrl)
+            }
+        }
+    }
+
     private func withdrawButtonTitle(_ currency: String) -> String {
         switch currency {
             case CHF_4217:
@@ -222,6 +239,9 @@ struct ManualWithdrawContent: View {
                 }
             } // Group
             .padding(.horizontal)
+        } else {
+            LoadingView(scopeInfo: scope, message: nil)
+                .task { await viewDidLoad2() }
         }
     }
 }
diff --git a/TalerWallet1/Views/Actions/Banking/ManualWithdrawDone.swift 
b/TalerWallet1/Views/Actions/Banking/ManualWithdrawDone.swift
index c346c11..6a7ecc6 100644
--- a/TalerWallet1/Views/Actions/Banking/ManualWithdrawDone.swift
+++ b/TalerWallet1/Views/Actions/Banking/ManualWithdrawDone.swift
@@ -29,6 +29,15 @@ struct ManualWithdrawDone: View {
         return try await model.getTransactionByIdT(transactionId, viewHandles: 
viewHandles)
     }
 
+    private func viewDidLoad() async {
+        if transactionId == nil {
+            if let result = try? await 
model.acceptManualWithdrawalM(amountToTransfer,
+                                                           baseUrl: baseURL,
+                                                       restrictAge: 0)
+            { transactionId = result.transactionId }
+        }
+    }
+
     var body: some View {
 #if PRINT_CHANGES
         let _ = Self._printChanges()
@@ -57,17 +66,12 @@ struct ManualWithdrawDone: View {
                 }
             } else {
                 LoadingView(scopeInfo: nil, message: baseURL.trimURL)
+                    .task { await viewDidLoad() }
             }
-        }.onAppear() {
+        }
+        .onAppear() {
             symLog.log("onAppear")
             DebugViewC.shared.setViewID(VIEW_WITHDRAW_ACCEPT, stack: 
stack.push())
-        }.task {
-            if transactionId == nil {
-                if let result = try? await 
model.acceptManualWithdrawalM(amountToTransfer,
-                                                                baseUrl: 
baseURL,
-                                                            restrictAge: 0)
-                { transactionId = result.transactionId }
-            }
         }
     }
 }
diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift 
b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift
index 1d6070f..d1af586 100644
--- a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift
+++ b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift
@@ -32,6 +32,25 @@ struct SendAmountV: View {
                              comment: "NavTitle: Send")
     }
 
+    private func viewDidLoad() async {
+        if let selectedBalance {
+            if selectedBalance.available.isZero {
+                // find another balance
+                balance = Balance.firstNonZero(controller.balances)
+            } else {
+                balance = selectedBalance
+            }
+        } else {
+            balance = Balance.firstNonZero(controller.balances)
+        }
+        if let balance {
+            balanceIndex = controller.balances.firstIndex(of: balance) ?? 0
+        } else {
+            balanceIndex = 0
+            balance = (controller.balances.count > 0) ? controller.balances[0] 
: nil
+        }
+    }
+
     var body: some View {
 #if PRINT_CHANGES
         let _ = Self._printChanges()
@@ -69,24 +88,7 @@ struct SendAmountV: View {
             .onDisappear {
                 symLog.log("❗️ \(navTitle) onDisappear")
             }
-            .task {
-                if let selectedBalance {
-                    if selectedBalance.available.isZero {
-                        // find another balance
-                        balance = Balance.firstNonZero(controller.balances)
-                    } else {
-                        balance = selectedBalance
-                    }
-                } else {
-                    balance = Balance.firstNonZero(controller.balances)
-                }
-                if let balance {
-                    balanceIndex = controller.balances.firstIndex(of: balance) 
?? 0
-                } else {
-                    balanceIndex = 0
-                    balance = (count > 0) ? controller.balances[0] : nil
-                }
-            }
+            .task { await viewDidLoad() }
 
         if #available(iOS 16.0, *) {
             if #available(iOS 16.4, *) {
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift 
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
index b0ef6fd..997166a 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
@@ -17,6 +17,18 @@ struct P2pAcceptDone: View {
     @EnvironmentObject private var controller: Controller
     @EnvironmentObject private var model: WalletModel
 
+    private func viewDidLoad() async {
+        if incoming {
+            if let _ = try? await model.acceptPeerPushCreditM(transactionId) {
+                dismissTop(stack.push())
+            }
+        } else {
+            if let _ = try? await model.confirmPeerPullDebitM(transactionId) {
+                dismissTop(stack.push())
+            }
+        }
+    }
+
     var body: some View {
 #if PRINT_CHANGES
         let _ = Self._printChanges()
@@ -28,22 +40,12 @@ struct P2pAcceptDone: View {
             .navigationBarBackButtonHidden(true)
 //            .interactiveDismissDisabled()           // can only use "Done" 
button to dismiss
             .navigationTitle(navTitle)
+            .task { await viewDidLoad() }
             .onAppear() {
                 symLog.log("onAppear")
                 DebugViewC.shared.setSheetID(incoming ? SHEET_RCV_P2P_ACCEPT
                                                       : SHEET_PAY_P2P_ACCEPT)
             }
-            .task {
-                if incoming {
-                    if let _ = try? await 
model.acceptPeerPushCreditM(transactionId) {
-                        dismissTop(stack.push())
-                    }
-                } else {
-                    if let _ = try? await 
model.confirmPeerPullDebitM(transactionId) {
-                        dismissTop(stack.push())
-                    }
-                }
-            }
     }
 }
 // MARK: -
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift 
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
index f1e14b2..74d191c 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
@@ -28,6 +28,18 @@ struct P2pReceiveURIView: View {
 
     let navTitle = String(localized: "P2P Receive")
 
+    private func viewDidLoad() async {
+        symLog.log(".task")
+        if let ppResponse = try? await 
model.preparePeerPushCreditM(url.absoluteString) {
+            let baseUrl = ppResponse.exchangeBaseUrl
+            exchange = try? await model.getExchangeByUrl(url: baseUrl)
+            await controller.checkCurrencyInfo(for: baseUrl, model: model)
+            peerPushCreditResponse = ppResponse
+        } else {
+            peerPushCreditResponse = nil
+        }
+    }
+
     var body: some View {
         VStack {
             if let peerPushCreditResponse {
@@ -98,15 +110,7 @@ struct P2pReceiveURIView: View {
             DebugViewC.shared.setSheetID(SHEET_RCV_P2P)
         }
         .task { // must be here and not at LoadingView(), because this needs 
to run a 2nd time after ToS was accepted
-            symLog.log(".task")
-            if let ppResponse = try? await 
model.preparePeerPushCreditM(url.absoluteString) {
-                let baseUrl = ppResponse.exchangeBaseUrl
-                exchange = try? await model.getExchangeByUrl(url: baseUrl)
-                await controller.checkCurrencyInfo(for: baseUrl, model: model)
-                peerPushCreditResponse = ppResponse
-            } else {
-                peerPushCreditResponse = nil
-            }
+            await viewDidLoad()
         }
     }
 }
diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift 
b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
index 1f351d5..cd3e23f 100644
--- a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
@@ -80,6 +80,49 @@ struct PayTemplateV: View {
         return nil
     }
 
+    @MainActor
+    private func viewDidLoad() async {
+        if let response = try? await 
model.checkPayForTemplateM(url.absoluteString) {
+            let details = response.templateDetails
+            let defaults = details.editableDefaults     // might be nil, or 
its fields might be nil
+                                                        // TODO: let the user 
choose a currency from supportedCurrencies[]
+            let supportedCurrencies = response.supportedCurrencies
+
+            /// checkPayForTemplate does not provide fees (yet)
+            let contract = details.templateContract     // specifies fixed 
amount/summary
+            amountIsEditable = contract.amount == nil
+            summaryIsEditable = contract.summary == nil
+
+            let prepCurrency = contract.currency ?? defaults?.currency ??
+                             (supportedCurrencies.count > 0 ? 
supportedCurrencies[0]
+                                                            : UNKNOWN)
+            let zeroAmount = Amount(currency: prepCurrency, cent: 0)
+            let prepAmount = contract.amount ?? defaults?.amount        // 
might be nil
+            let prepSummary = contract.summary ?? defaults?.summary     // 
might be nil
+//          symLog.log("LoadingView.task preparePayForTemplate")
+            /// preparePayForTemplate will make a network call to the merchant 
and create a TX
+            ///  -> we only want to do this after the user entered amount and 
subject - but before confirmation of course
+//          if let result = await preparePayForTemplate(model: model,
+//                                                        url: url,
+//                                                     amount: 
amountIsEditable ? prepAmount ?? zeroAmount
+//                                                                             
 : nil,
+//                                                    summary: 
summaryIsEditable ? prepSummary ?? " "
+//                                                                             
  : nil,
+//                                                   announce: announce)
+//          {   symLog.log("preparePayForTemplate finished")
+                amountToTransfer = prepAmount ?? zeroAmount
+                summary = prepSummary ?? EMPTYSTRING
+                templateContract = contract
+//              insufficient = result.insufficient
+//              feeAmount = result.feeAmount
+//              feeStr = result.feeStr
+//              preparePayResult = result.ppCheck
+//          } else {
+//              symLog.log("preparePayForTemplateM failed")
+//          }
+        }
+
+    }
     var body: some View {
         if let templateContract {       // preparePayResult
 //            let currency = templateContract.currency ?? 
templateContract.amount?.currencyStr ?? UNKNOWN
@@ -180,43 +223,7 @@ struct PayTemplateV: View {
             }
         } else {
             LoadingView(scopeInfo: nil, message: url.host)
-                .task {
-                    if let details = try? await 
model.checkPayForTemplateM(url.absoluteString) {
-                        /// checkPayForTemplateM does not provide fees (yet)
-                        let contract = 
details.templateDetails.templateContract     // specifies fixed amount/summary
-                        amountIsEditable = contract.amount == nil
-                        summaryIsEditable = contract.summary == nil
-                        let defaults = 
details.templateDetails.editableDefaults     // might be nil, or its fields 
might be nil
-                        // TODO: let the user choose a currency from 
supportedCurrencies[]
-                        let prepCurrency = contract.currency ?? 
defaults?.currency ??
-                                    (details.supportedCurrencies.count > 0 ? 
details.supportedCurrencies[0]
-                                                                           : 
UNKNOWN)
-                        let zeroAmount = Amount(currency: prepCurrency, cent: 
0)
-                        let prepAmount = contract.amount ?? defaults?.amount   
     // might be nil
-                        let prepSummary = contract.summary ?? 
defaults?.summary     // might be nil
-//                        symLog.log("LoadingView.task preparePayForTemplate")
-                        /// preparePayForTemplate will make a network call to 
the merchant and create a TX
-                        ///  -> we only want to do this after the user entered 
amount and subject - but before confirmation of course
-//                        if let result = await preparePayForTemplate(model: 
model,
-//                                                                      url: 
url,
-//                                                                   amount: 
amountIsEditable ? prepAmount ?? zeroAmount
-//                                                                             
               : nil,
-//                                                                  summary: 
summaryIsEditable ? prepSummary ?? " "
-//                                                                             
                : nil,
-//                                                                 announce: 
announce)
-//                        {   symLog.log("preparePayForTemplate finished")
-                            amountToTransfer = prepAmount ?? zeroAmount
-                            summary = prepSummary ?? EMPTYSTRING
-                            templateContract = contract
-//                            insufficient = result.insufficient
-//                            feeAmount = result.feeAmount
-//                            feeStr = result.feeStr
-//                            preparePayResult = result.ppCheck
-//                        } else {
-//                            symLog.log("preparePayForTemplateM failed")
-//                        }
-                    }
-                }
+                .task { await viewDidLoad() }
         }
     }
 }
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift 
b/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift
index 676d104..1fc8da1 100644
--- a/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift
@@ -23,6 +23,16 @@ struct PaymentDone: View {
         return try await model.getTransactionByIdT(transactionId, viewHandles: 
viewHandles)
     }
 
+    @MainActor
+    private func viewDidLoad() async {
+        if let confirmPayResult = try? await model.confirmPayM(transactionId) {
+//          symLog.log(confirmPayResult as Any)
+            if confirmPayResult.type == "done" {
+                paymentDone = true
+            }
+        }
+    }
+
     var body: some View {
 #if PRINT_CHANGES
         let _ = Self._printChanges()
@@ -52,14 +62,7 @@ struct PaymentDone: View {
                 }
             } else {
                 LoadingView(scopeInfo: nil, message: "Paying...")
-                    .task {
-                        if let confirmPayResult = try? await 
model.confirmPayM(transactionId) {
-//                          symLog.log(confirmPayResult as Any)
-                            if confirmPayResult.type == "done" {
-                                paymentDone = true
-                            }
-                        }
-                    }
+                    .task { await viewDidLoad() }
             }
         }.onAppear() {
             symLog.log("onAppear")
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift 
b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
index 956dadd..4366e1c 100644
--- a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -111,6 +111,25 @@ struct PaymentView: View, Sendable {
         symLog.log("Couldn't load Info(for: \(result.amountRaw.currencyStr))")
     }
 
+    @MainActor
+    private func viewDidLoad() async {
+//        symLog.log(".task")
+        if template {
+            if let templateResponse = try? await 
model.preparePayForTemplateM(url.absoluteString,
+                                                                     amount: 
amountIsEditable ? amountToTransfer : nil,
+                                                                    summary: 
summaryIsEditable ? summary : nil) {
+                await checkCurrencyInfo(for: templateResponse)
+                preparePayResult = templateResponse
+            }
+        } else {
+            if let payResponse = try? await 
model.preparePayForUriM(url.absoluteString) {
+                amountToTransfer = payResponse.amountRaw
+                await checkCurrencyInfo(for: payResponse)
+                preparePayResult = payResponse
+            }
+        }
+    }
+
     var body: some View {
       Group {
         if let preparePayResult {
@@ -233,24 +252,7 @@ struct PaymentView: View, Sendable {
             }
         } else {
             LoadingView(scopeInfo: nil, message: url.host)
-                .task { // this runs only once
-                    symLog.log(".task")
-                    if template {
-                        if let payResponse = try? await 
model.preparePayForTemplateM(url.absoluteString,
-                                                                               
      amount: amountIsEditable ? amountToTransfer : nil,
-                                                                               
      summary: summaryIsEditable ? summary : nil) {
-                            await checkCurrencyInfo(for: payResponse)
-                            preparePayResult = payResponse
-                        }
-                    } else {
-                        if let result = try? await 
model.preparePayForUriM(url.absoluteString) {
-                            amountToTransfer = result.amountRaw
-                            await checkCurrencyInfo(for: result)
-                            preparePayResult = result
-                        }
-                    }
-                }
-//                .task { await viewDidLoad() }
+                .task { await viewDidLoad() }
         }
       }.onAppear() {
           symLog.log("onAppear")
diff --git a/TalerWallet1/Views/Sheets/Refund/RefundURIView.swift 
b/TalerWallet1/Views/Sheets/Refund/RefundURIView.swift
index 9ca490a..1106361 100644
--- a/TalerWallet1/Views/Sheets/Refund/RefundURIView.swift
+++ b/TalerWallet1/Views/Sheets/Refund/RefundURIView.swift
@@ -27,6 +27,14 @@ struct RefundURIView: View {
         return try await model.getTransactionByIdT(transactionId, viewHandles: 
viewHandles)
     }
 
+    private func viewDidLoad() async {
+        symLog.log(".task")
+        if let result = try? await model.startRefundForUriM(url: 
url.absoluteString) {
+            refundTransactionId = result
+            transaction = try? await model.getTransactionByIdM(result)
+        }
+    }
+
     var body: some View {
         if let refundTransactionId, let transaction {
             let common = transaction.common
@@ -55,13 +63,7 @@ struct RefundURIView: View {
             }
         } else {
             LoadingView(scopeInfo: nil, message: url.host)
-                .task {
-                    symLog.log(".task")
-                    if let result = try? await model.startRefundForUriM(url: 
url.absoluteString) {
-                        refundTransactionId = result
-                        transaction = try? await 
model.getTransactionByIdM(result)
-                    }
-                }
+                .task { await viewDidLoad() }
         }
     }
 }
diff --git 
a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift 
b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift
index 493cd64..fc7c83a 100644
--- a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift
+++ b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift
@@ -31,6 +31,21 @@ struct WithdrawAcceptDone: View {
         return response
     }
 
+    private func viewDidLoad() async {
+        if let exchangeBaseUrl {
+            // TODO: restrictAge
+            if let result = try? await 
model.sendAcceptIntWithdrawalM(exchangeBaseUrl,
+                                                         withdrawURL: 
url.absoluteString,
+                                                              amount: 
amountToTransfer,
+                                                         restrictAge: nil
+            ) {
+                let confirmTransferUrl = result.confirmTransferUrl
+                symLog.log(confirmTransferUrl)
+                transactionId = result.transactionId
+            }
+        }
+    }
+
     var body: some View {
 #if PRINT_CHANGES
         let _ = Self._printChanges()
@@ -67,19 +82,11 @@ struct WithdrawAcceptDone: View {
                 LoadingView(scopeInfo: nil, message: exchangeBaseUrl?.trimURL
                                                   ?? "Bank Authorization")
             }
-        }.onAppear() {
+        }
+        .task { await viewDidLoad() }
+        .onAppear() {
             symLog.log("onAppear")
             DebugViewC.shared.setSheetID(SHEET_WITHDRAW_CONFIRM)
-        }.task {
-            if let exchangeBaseUrl {
-                // TODO: restrictAge
-                if let result = try? await 
model.sendAcceptIntWithdrawalM(exchangeBaseUrl, withdrawURL: url.absoluteString,
-                                                                          
amount: amountToTransfer, restrictAge: nil) {
-                    let confirmTransferUrl = result.confirmTransferUrl
-                    symLog.log(confirmTransferUrl)
-                    transactionId = result.transactionId
-                }
-            }
         }
     }
 }
diff --git a/TalerWallet1/Views/Sheets/WithdrawExchangeV.swift 
b/TalerWallet1/Views/Sheets/WithdrawExchangeV.swift
index 6d038ca..55bd32d 100644
--- a/TalerWallet1/Views/Sheets/WithdrawExchangeV.swift
+++ b/TalerWallet1/Views/Sheets/WithdrawExchangeV.swift
@@ -25,6 +25,30 @@ struct WithdrawExchangeV: View {
 
     let navTitle = String(localized: "Checking Link")
 
+    private func viewDidLoad() async {
+        if exchange == nil {
+            symLog.log(".task")
+            if let withdrawExchange = try? await 
model.loadWithdrawalExchangeForUriM(url.absoluteString) {
+                let baseUrl = withdrawExchange.exchangeBaseUrl
+                symLog.log("getExchangeByUrl(\(baseUrl))")
+                if let exc = try? await model.getExchangeByUrl(url: baseUrl) {
+                    // let the controller collect CurrencyInfo from this 
formerly unknown exchange
+                    let _ = try? await controller.getInfo(from: baseUrl, 
model: model)
+                    if let amount = withdrawExchange.amount {
+                        amountToTransfer = amount
+                    } else {
+                        let currency = exc.scopeInfo.currency
+                        amountToTransfer.setCurrency(currency)
+                        // is already Amount.zero()
+                    }
+                    exchange = exc
+                } else {
+                    exchange = nil
+                }
+            }
+        }
+    }
+
     var body: some View {
 #if PRINT_CHANGES
         let _ = Self._printChanges()
@@ -43,29 +67,7 @@ struct WithdrawExchangeV: View {
             }
         } else {
             LoadingView(scopeInfo: nil, message: "No exchangeBaseUrl!")
-            .task {
-                if exchange == nil {
-                    symLog.log(".task")
-                    if let withdrawExchange = try? await 
model.loadWithdrawalExchangeForUriM(url.absoluteString) {
-                        let baseUrl = withdrawExchange.exchangeBaseUrl
-                        symLog.log("getExchangeByUrl(\(baseUrl))")
-                        if let exc = try? await model.getExchangeByUrl(url: 
baseUrl) {
-                            // let the controller collect CurrencyInfo from 
this formerly unknown exchange
-                            let _ = try? await controller.getInfo(from: 
baseUrl, model: model)
-                            if let amount = withdrawExchange.amount {
-                                amountToTransfer = amount
-                            } else {
-                                let currency = exc.scopeInfo.currency
-                                amountToTransfer.setCurrency(currency)
-                                // is already Amount.zero()
-                            }
-                            exchange = exc
-                        } else {
-                            exchange = nil
-                        }
-                    }
-                }
-            }
+                .task { await viewDidLoad() }
         }
     }
 }
diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift 
b/TalerWallet1/Views/Transactions/ManualDetailsV.swift
index 4a5a1d0..4bf2d16 100644
--- a/TalerWallet1/Views/Transactions/ManualDetailsV.swift
+++ b/TalerWallet1/Views/Transactions/ManualDetailsV.swift
@@ -137,6 +137,12 @@ struct ManualDetailsV: View {
         }
     }
 
+    private func viewDidLoad(_ payto: String) async {
+        if let specs = try? await model.getQrCodesForPaytoM(payto) {
+            qrCodeSpecs = specs ?? []
+        }
+    }
+
     var body: some View {
         if let accountDetails = details.exchangeCreditAccountDetails {
             let validDetails = validDetails(accountDetails)
@@ -227,11 +233,7 @@ struct ManualDetailsV: View {
                             }
                         }.id(listID)
                             .talerFont(.body)
-                            .task {
-                                if let specs = try? await 
model.getQrCodesForPaytoM(payto) {
-                                    qrCodeSpecs = specs ?? []
-                                }
-                            }
+                            .task { await viewDidLoad(payto) }
                     } else {
                         // TODO: Error No payto URL
                     }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]