gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 27/35: Postpone update until onAppear


From: gnunet
Subject: [taler-taler-ios] 27/35: Postpone update until onAppear
Date: Thu, 27 Jul 2023 09:10:00 +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 73dc3c18fc5d571d68d45d939803afaeab53d8a0
Author: Marc Stibane <marc@taler.net>
AuthorDate: Tue Jul 25 16:31:16 2023 +0200

    Postpone update until onAppear
---
 TalerWallet1/Views/Balances/BalancesListView.swift | 23 +++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift 
b/TalerWallet1/Views/Balances/BalancesListView.swift
index 00c65c9..d1b31d2 100644
--- a/TalerWallet1/Views/Balances/BalancesListView.swift
+++ b/TalerWallet1/Views/Balances/BalancesListView.swift
@@ -130,6 +130,9 @@ extension BalancesListView {
         @Binding var summary: String
         var reloadAction: () async -> Int
 
+        @State private var isActive = true
+        @State private var shouldReload = false
+
         var body: some View {
 #if DEBUG
             let _ = Self._printChanges()
@@ -151,12 +154,26 @@ extension BalancesListView {
                 }
                 .listStyle(myListStyle.style).anyView
             }
+            .onAppear() {
+                isActive = true
+                if shouldReload {
+                    shouldReload = false
+                    symLog?.log(".onAppear ==>  shouldReload was true, 
reloading now")
+                    Task { await reloadAction() }
+                }
+            }
+            .onDisappear() {
+                isActive = false
+            }
             .onNotification(.BalanceChange) { notification in
                 // reload balances on receiving BalanceChange notification ...
                 // doesn't need to be received on main thread because we just 
reload in a background task anyway
-                symLog?.log(".onNotification(.BalanceChange) ==> reload")
-                Task {
-                    await reloadAction()
+                if isActive {
+                    symLog?.log(".onNotification(.BalanceChange) ==> reload")
+                    Task { await reloadAction() }
+                } else {
+                    symLog?.log(".onNotification(.BalanceChange) ==> reload 
postponed, shouldReload = true")
+                    shouldReload = true
                 }
             }
         } // body

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