[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 01/07: Error handling, Amount.diff
From: |
gnunet |
Subject: |
[taler-taler-ios] 01/07: Error handling, Amount.diff |
Date: |
Wed, 22 Feb 2023 16:16:28 +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 3add557802b4a5c0a4707259176998d19a9ce7d1
Author: Marc Stibane <marc@taler.net>
AuthorDate: Thu Feb 9 09:24:16 2023 +0100
Error handling, Amount.diff
---
TalerWallet1/Controllers/TalerWallet1App.swift | 2 +-
TalerWallet1/Model/WalletInitModel.swift | 6 ++++--
.../Views/Balances/CurrenciesListView.swift | 9 ++++++--
TalerWallet1/Views/Exchange/ExchangeListView.swift | 4 ++--
TalerWallet1/Views/Payment/PaymentAcceptView.swift | 2 +-
.../Views/Pending/PendingOpsListView.swift | 16 +++++++++++---
.../Views/Transactions/TransactionDetail.swift | 2 +-
.../Views/Transactions/TransactionsListView.swift | 25 +++++++++++++---------
.../Views/Withdraw/WithdrawAcceptView.swift | 2 +-
9 files changed, 45 insertions(+), 23 deletions(-)
diff --git a/TalerWallet1/Controllers/TalerWallet1App.swift
b/TalerWallet1/Controllers/TalerWallet1App.swift
index 11f8645..3128077 100644
--- a/TalerWallet1/Controllers/TalerWallet1App.swift
+++ b/TalerWallet1/Controllers/TalerWallet1App.swift
@@ -43,7 +43,7 @@ struct TalerWallet1App: App {
.handlesExternalEvents(preferring: ["*"], allowing: ["*"])
.task {
symLog.log("task -> initWalletCore")
- try? await controller.initWalletCore()
+ try! await controller.initWalletCore() // will
(and should) crash on failure
symLog.log("task done")
}
}
diff --git a/TalerWallet1/Model/WalletInitModel.swift
b/TalerWallet1/Model/WalletInitModel.swift
index e254d41..7be0dff 100644
--- a/TalerWallet1/Model/WalletInitModel.swift
+++ b/TalerWallet1/Model/WalletInitModel.swift
@@ -27,12 +27,14 @@ fileprivate struct WalletBackendInitRequest:
WalletBackendFormattedRequest {
func operation() -> String { return "init" }
func args() -> Args {
return Args(persistentStoragePath: persistentStoragePath,
- cryptoWorkerType: "sync")
+// cryptoWorkerType: "sync",
+ logLevel: "info") // "trace", "info", "warn",
"error", "none"
}
struct Args: Encodable {
var persistentStoragePath: String
- var cryptoWorkerType: String?
+// var cryptoWorkerType: String
+ var logLevel: String
}
var persistentStoragePath: String
diff --git a/TalerWallet1/Views/Balances/CurrenciesListView.swift
b/TalerWallet1/Views/Balances/CurrenciesListView.swift
index a40b074..192d531 100644
--- a/TalerWallet1/Views/Balances/CurrenciesListView.swift
+++ b/TalerWallet1/Views/Balances/CurrenciesListView.swift
@@ -69,8 +69,13 @@ extension CurrenciesListView {
}
.navigationBarTitleDisplayMode(.large) // .inline
.refreshable {
- symLog?.log("refreshing")
- try? await reloadAction() // TODO: catch error
+ do {
+ symLog?.log("refreshing")
+ try await reloadAction()
+ } catch {
+ // TODO: error
+ symLog?.log(error.localizedDescription)
+ }
}
}
}
diff --git a/TalerWallet1/Views/Exchange/ExchangeListView.swift
b/TalerWallet1/Views/Exchange/ExchangeListView.swift
index b4b8b9f..fbd52e4 100644
--- a/TalerWallet1/Views/Exchange/ExchangeListView.swift
+++ b/TalerWallet1/Views/Exchange/ExchangeListView.swift
@@ -85,11 +85,11 @@ extension ExchangeListView {
}
.navigationBarTitleDisplayMode(.large) // .inline
.refreshable {
- symLog.log("refreshing")
do {
+ symLog.log("refreshing")
try await reloadAction()
} catch {
- // TODO: catch error
+ // TODO: error
symLog.log(error.localizedDescription)
}
}
diff --git a/TalerWallet1/Views/Payment/PaymentAcceptView.swift
b/TalerWallet1/Views/Payment/PaymentAcceptView.swift
index 7920b87..26eb916 100644
--- a/TalerWallet1/Views/Payment/PaymentAcceptView.swift
+++ b/TalerWallet1/Views/Payment/PaymentAcceptView.swift
@@ -35,7 +35,7 @@ struct PaymentAcceptView: View {
symLog { Group {
let raw = detailsForAmount.amountRaw
let effective = detailsForAmount.amountEffective
- let fee = try! effective - raw
+ let fee = try! Amount.diff(raw, effective) // TODO: different
currencies
Form {
AmountView(title: "Amount to pay:",
value: raw.readableDescription, color:
Color(UIColor.label))
diff --git a/TalerWallet1/Views/Pending/PendingOpsListView.swift
b/TalerWallet1/Views/Pending/PendingOpsListView.swift
index 30a5de3..a4d9e61 100644
--- a/TalerWallet1/Views/Pending/PendingOpsListView.swift
+++ b/TalerWallet1/Views/Pending/PendingOpsListView.swift
@@ -37,7 +37,12 @@ struct PendingOpsListView: View {
}
}.task {
symLog.log(".task")
- try? await reloadAction() // TODO: catch error
+ do {
+ try await reloadAction()
+ } catch {
+ // TODO: show error
+ symLog.log(error.localizedDescription)
+ }
}
}
}
@@ -56,8 +61,13 @@ extension PendingOpsListView {
}
.navigationBarTitleDisplayMode(.large) // .inline
.refreshable {
- symLog?.log("refreshing")
- try? await reloadAction() // TODO: catch error
+ do {
+ symLog?.log("refreshing")
+ try await reloadAction()
+ } catch {
+ // TODO: error
+ symLog?.log(error.localizedDescription)
+ }
}
}
}
diff --git a/TalerWallet1/Views/Transactions/TransactionDetail.swift
b/TalerWallet1/Views/Transactions/TransactionDetail.swift
index 84b442a..d092c79 100644
--- a/TalerWallet1/Views/Transactions/TransactionDetail.swift
+++ b/TalerWallet1/Views/Transactions/TransactionDetail.swift
@@ -22,7 +22,7 @@ struct TransactionDetail: View {
var body: some View {
let raw = transaction.amountRaw
let effective = transaction.amountEffective
- let fee = try! Amount.diff(raw, effective)
+ let fee = try! Amount.diff(raw, effective) // TODO: different
currencies
let dateString = TalerDater.dateString(from: transaction.timestamp)
VStack() {
diff --git a/TalerWallet1/Views/Transactions/TransactionsListView.swift
b/TalerWallet1/Views/Transactions/TransactionsListView.swift
index 8f9a6a3..9026a97 100644
--- a/TalerWallet1/Views/Transactions/TransactionsListView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionsListView.swift
@@ -53,12 +53,12 @@ extension TransactionsListView {
var body: some View {
let transactions = viewModel.transactions!
- List(transactions, id: \.transactionId) { transaction in
- NavigationLink {
- TransactionDetail(transaction: transaction)
- } label: {
- TransactionRow(transaction: transaction)
- }
+ List(transactions, id: \.transactionId) { transaction in
+ NavigationLink {
+ TransactionDetail(transaction: transaction)
+ } label: {
+ TransactionRow(transaction: transaction)
+ }
.swipeActions(edge: .leading, allowsFullSwipe: true) {
Button {
symLog?.log("bookmarked
\(transaction.transactionId)")
@@ -75,12 +75,17 @@ extension TransactionsListView {
Label("Delete", systemImage: "trash")
}
}
- }
- .navigationBarTitleDisplayMode(.large) // .inline
- .refreshable {
+ }
+ .navigationBarTitleDisplayMode(.large) // .inline
+ .refreshable {
+ do {
symLog?.log("refreshing")
- try? await reloadAction() // TODO: catch error
+ try await reloadAction()
+ } catch {
+ // TODO: error
+ symLog?.log(error.localizedDescription)
}
+ }
}
}
}
diff --git a/TalerWallet1/Views/Withdraw/WithdrawAcceptView.swift
b/TalerWallet1/Views/Withdraw/WithdrawAcceptView.swift
index becc6dd..4f9578c 100644
--- a/TalerWallet1/Views/Withdraw/WithdrawAcceptView.swift
+++ b/TalerWallet1/Views/Withdraw/WithdrawAcceptView.swift
@@ -37,7 +37,7 @@ struct WithdrawAcceptView: View {
case .receivedAmountDetails, .receivedTOS, .receivedTOSAck:
let raw = detailsForAmount.amountRaw
let effective = detailsForAmount.amountEffective
- let fee = try! raw - effective
+ let fee = try! Amount.diff(raw, effective) // TODO:
different currencies
Form {
AmountView(title: "Chosen amount to withdraw:",
value: raw.readableDescription, color:
Color(UIColor.label))
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] branch master updated (df4fe35 -> 4f2b20c), gnunet, 2023/02/22
- [taler-taler-ios] 01/07: Error handling, Amount.diff,
gnunet <=
- [taler-taler-ios] 04/07: Constants, cleanup, gnunet, 2023/02/22
- [taler-taler-ios] 03/07: added ext+taler and web+taler to the list of recognized URL schemes, gnunet, 2023/02/22
- [taler-taler-ios] 06/07: Info & SceneConfigurations, v0.9.2, bundleID, gnunet, 2023/02/22
- [taler-taler-ios] 02/07: ported remaining sync wallet-core funcs to try await, gnunet, 2023/02/22
- [taler-taler-ios] 05/07: Transaction definition and JSON decoding - Bug 7678, gnunet, 2023/02/22
- [taler-taler-ios] 07/07: Transaction list and details, gnunet, 2023/02/22