diff options
author | Iván Ávalos <avalos@disroot.org> | 2024-03-22 11:20:32 -0600 |
---|---|---|
committer | Marc Stibane <marc@taler.net> | 2024-04-11 22:44:00 +0200 |
commit | 7cecef9af7fac6be732c7983f34fd3ca0fcc4200 (patch) | |
tree | 2fb73ec12238efb703d6edbc39f7d8a8053f5952 | |
parent | fa746337d19502f678b9425a0be025745e1c2ba5 (diff) | |
download | taler-ios-7cecef9af7fac6be732c7983f34fd3ca0fcc4200.tar.gz taler-ios-7cecef9af7fac6be732c7983f34fd3ca0fcc4200.tar.bz2 taler-ios-7cecef9af7fac6be732c7983f34fd3ca0fcc4200.zip |
Prepare notification error handling
-rw-r--r-- | TalerWallet1/Backend/WalletCore.swift | 6 | ||||
-rw-r--r-- | TalerWallet1/Controllers/PublicConstants.swift | 3 | ||||
-rw-r--r-- | TalerWallet1/Model/Transaction.swift | 1 | ||||
-rw-r--r-- | TalerWallet1/Views/Main/MainView.swift | 8 |
4 files changed, 18 insertions, 0 deletions
diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift index 20c614f..37fe22d 100644 --- a/TalerWallet1/Backend/WalletCore.swift +++ b/TalerWallet1/Backend/WalletCore.swift @@ -197,6 +197,11 @@ extension WalletCore { logger.info("No State change: \(decoded.transactionId, privacy: .private(mask: .hash))") return } + + if decoded.errorInfo == nil { + postNotification(.Error, userInfo: [NOTIFICATIONERROR: decoded.errorInfo]) + } + let components = decoded.transactionId.components(separatedBy: ":") if components.count >= 3 { // txn:$txtype:$uid if let type = TransactionType(rawValue: components[1]) { @@ -307,6 +312,7 @@ print("\n❗️ WalletCore.swift:251 Notification: ", anyPayload, "\n") / } } catch let error { symLog.log("Error \(error) parsing notification: \(anyPayload)") // TODO: .error + postNotification(.Error, userInfo: [NOTIFICATIONERROR: error]) // TODO: if DevMode then should log into file for user } } diff --git a/TalerWallet1/Controllers/PublicConstants.swift b/TalerWallet1/Controllers/PublicConstants.swift index 2eb2ad8..5b563d0 100644 --- a/TalerWallet1/Controllers/PublicConstants.swift +++ b/TalerWallet1/Controllers/PublicConstants.swift @@ -59,6 +59,8 @@ public let TALERURI = "talerUri" public let TRANSACTIONTRANSITION = "transactionTransition" public let TRANSACTIONID = "transactionID" +public let NOTIFICATIONERROR = "error" + /// Notifications sent by wallet-core extension Notification.Name { static let BalanceChange = Notification.Name("balance-change") @@ -79,6 +81,7 @@ extension Notification.Name { // static let PayOperationSuccess = Notification.Name("pay-operation-success") static let ProposalAccepted = Notification.Name("proposal-accepted") static let ProposalDownloaded = Notification.Name("proposal-downloaded") + static let Error = Notification.Name("error") } /// Notifications for internal synchronization diff --git a/TalerWallet1/Model/Transaction.swift b/TalerWallet1/Model/Transaction.swift index dc2d7a6..85ed2d3 100644 --- a/TalerWallet1/Model/Transaction.swift +++ b/TalerWallet1/Model/Transaction.swift @@ -142,6 +142,7 @@ struct TransactionTransition: Codable { // Notification var newTxState: TransactionState var transactionId: String var experimentalUserData: String? // KYC + var errorInfo: WalletBackendResponseError? } enum TxAction: String, Codable { diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift index 168b548..d9f6af1 100644 --- a/TalerWallet1/Views/Main/MainView.swift +++ b/TalerWallet1/Views/Main/MainView.swift @@ -260,6 +260,12 @@ extension MainView { shouldReloadBalances += 1 selectedTab = .balances } + .onNotification(.Error) { notification in + if let error = notification.userInfo?[NOTIFICATIONERROR] as? Error { + model.showError(.error(error)) + controller.playSound(0) + } + } .onChange(of: balances) { newArray in for balance in newArray { let scope = balance.scopeInfo @@ -270,6 +276,8 @@ extension MainView { await controller.setInfo(info) } catch { // TODO: error handling - couldn't get CurrencyInfo logger.error("Couldn't get info for: \(scope.currency, privacy: .public)\n\(error)") + model.showError(.error(error)) + controller.playSound(0) } } } |