gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 24/54: balance-change


From: gnunet
Subject: [taler-taler-ios] 24/54: balance-change
Date: Fri, 30 Jun 2023 22:33:56 +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 8edd36d8c090ebb67c7ec72988d8fe65228cd6c4
Author: Marc Stibane <marc@taler.net>
AuthorDate: Tue Jun 27 14:20:34 2023 +0200

    balance-change
---
 TalerWallet1/Backend/WalletCore.swift              |  3 ++-
 TalerWallet1/Controllers/PublicConstants.swift     |  1 +
 TalerWallet1/Views/Balances/BalancesListView.swift | 17 +++++++++++++----
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/TalerWallet1/Backend/WalletCore.swift 
b/TalerWallet1/Backend/WalletCore.swift
index 06e60fb..48ec604 100644
--- a/TalerWallet1/Backend/WalletCore.swift
+++ b/TalerWallet1/Backend/WalletCore.swift
@@ -202,6 +202,8 @@ print("\n❗️ \(pendingOp): \(id)\n")        // this is a new 
pendingOp I have
                     try handleStateTransition(jsonData)
                 case Notification.Name.PendingOperationProcessed.rawValue:
                     try handlePendingProcessed(payload)
+                case Notification.Name.BalanceChange.rawValue:
+                    postNotification(.BalanceChange)
                 case Notification.Name.ExchangeAdded.rawValue:
                     postNotification(.ExchangeAdded)
                 case Notification.Name.ReserveNotYetFound.rawValue:
@@ -224,7 +226,6 @@ print("\n❗️ \(pendingOp): \(id)\n")        // this is a new 
pendingOp I have
 //                     "pay-operation-success",
 //                     "withdrawal-group-bank-confirmed",          // replaced 
by transaction-state-transition
 //                     "withdrawal-group-reserve-ready",
-//                     "coin-withdrawn",                           // totally 
useless since wallet-core handles coins in bulk
 //                     "waiting-for-retry",                        // Bla Bla 
Bla
                 case "refresh-started", "refresh-melted",
                      "refresh-revealed", "refresh-unwarranted":
diff --git a/TalerWallet1/Controllers/PublicConstants.swift 
b/TalerWallet1/Controllers/PublicConstants.swift
index 3a117ff..99e1f46 100644
--- a/TalerWallet1/Controllers/PublicConstants.swift
+++ b/TalerWallet1/Controllers/PublicConstants.swift
@@ -28,6 +28,7 @@ public let TALERURI = "talerUri"
 public let TRANSACTIONTRANSITION = "transactionTransition"
 
 extension Notification.Name {
+    static let BalanceChange = Notification.Name("balance-change")
     static let TransactionStateTransition = 
Notification.Name(TransactionTransition.TransitionType.transition.rawValue)
     static let ExchangeAdded = Notification.Name("exchange-added")
     static let PendingOperationProcessed = 
Notification.Name("pending-operation-processed")
diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift 
b/TalerWallet1/Views/Balances/BalancesListView.swift
index 09a0119..cd6022e 100644
--- a/TalerWallet1/Views/Balances/BalancesListView.swift
+++ b/TalerWallet1/Views/Balances/BalancesListView.swift
@@ -110,6 +110,7 @@ extension BalancesListView {
         @Binding var summary: String
         var reloadAction: () async -> Void
 
+        @State private var shouldLoad = false
         var body: some View {
 #if DEBUG
             let _ = Self._printChanges()
@@ -124,14 +125,22 @@ extension BalancesListView {
                 .refreshable {
                     symLog?.log("refreshing")
                     await reloadAction()      // this closure is already 
async, no need for a Task
+                    // TODO: reload transactions
                 }
                 .listStyle(myListStyle.style).anyView
             }
-            // automatically fetch balances after receiving 
transaction-state-transition ...
-            .onNotification(.TransactionStateTransition) { notification in
+            .onAppear {
+                if shouldLoad {
+                    shouldLoad = false
+                    symLog?.log(".onAppear: shouldLoad ==> reloading balances")
+                    Task { await reloadAction() }
+                }
+            }
+            // automatically reload balances after receiving BalanceChange 
notification ...
+            .onNotification(.BalanceChange) { notification in
                 // doesn't need to be received on main thread because we just 
reload in the background anyway
-                symLog?.log(".onNotification(.TransactionStateTransition) ==> 
reloading balances")
-                Task { await reloadAction() }
+                symLog?.log(".onNotification(.BalanceChange) ==> shouldLoad = 
true")
+                shouldLoad = true
             }
         } // body
     } // Content

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