gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 11/17: Prepare notification error handling


From: gnunet
Subject: [taler-taler-ios] 11/17: Prepare notification error handling
Date: Thu, 11 Apr 2024 23:13:43 +0200

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 7cecef9af7fac6be732c7983f34fd3ca0fcc4200
Author: Iván Ávalos <avalos@disroot.org>
AuthorDate: Fri Mar 22 11:20:32 2024 -0600

    Prepare notification error handling
---
 TalerWallet1/Backend/WalletCore.swift          | 6 ++++++
 TalerWallet1/Controllers/PublicConstants.swift | 3 +++
 TalerWallet1/Model/Transaction.swift           | 1 +
 TalerWallet1/Views/Main/MainView.swift         | 8 ++++++++
 4 files changed, 18 insertions(+)

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)
                             }
                         }
                     }

-- 
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]