taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit 9525345216c93c6d48e0fc2270d817b2336a5a78
parent 107a2f6d79926999ab204564a8e2b77a20b9778e
Author: Marc Stibane <marc@taler.net>
Date:   Wed,  2 Oct 2024 19:22:24 +0200

ExchangeDeleted

Diffstat:
MTalerWallet1/Backend/WalletCore.swift | 3+++
MTalerWallet1/Controllers/PublicConstants.swift | 1+
MTalerWallet1/Views/Banking/ExchangeListView.swift | 8+++++++-
3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift @@ -323,6 +323,9 @@ extension WalletCore { case Notification.Name.ExchangeAdded.rawValue: symLog.log(anyPayload) postNotification(.ExchangeAdded) + case Notification.Name.ExchangeDeleted.rawValue: + symLog.log(anyPayload) + postNotification(.ExchangeDeleted) case Notification.Name.ReserveNotYetFound.rawValue: if let reservePub = payload.reservePub { let userInfo = ["reservePub" : reservePub] diff --git a/TalerWallet1/Controllers/PublicConstants.swift b/TalerWallet1/Controllers/PublicConstants.swift @@ -93,6 +93,7 @@ extension Notification.Name { static let Idle = Notification.Name("idle") static let BalanceChange = Notification.Name("balance-change") static let ExchangeAdded = Notification.Name("exchange-added") + static let ExchangeDeleted = Notification.Name("exchange-deleted") static let ExchangeStateTransition = Notification.Name(ExchangeTransition.TransitionType.transition.rawValue) static let TransactionStateTransition = Notification.Name(TransactionTransition.TransitionType.transition.rawValue) static let TransactionDone = Notification.Name("transaction-done") diff --git a/TalerWallet1/Views/Banking/ExchangeListView.swift b/TalerWallet1/Views/Banking/ExchangeListView.swift @@ -27,6 +27,7 @@ struct ExchangeListView: View { if let _ = try? await model.addExchange(url: exchange) { symLog.log("added: \(exchange)") announce("added: \(exchange)") + NotificationCenter.default.post(name: .ExchangeAdded, object: nil, userInfo: nil) } } } @@ -84,7 +85,7 @@ struct ExchangeListCommonV { func reloadExchanges() async -> Void { if let exc = try? await model.listExchangesM() { - exchanges = exc + withAnimation { exchanges = exc } } } } @@ -146,6 +147,11 @@ extension ExchangeListCommonV: View { symLog?.log(".onNotification(.ExchangeAdded) ==> reloading exchanges") Task { await reloadExchanges() } // runs on MainActor } + .onNotification(.ExchangeDeleted) { notification in + // doesn't need to be received on main thread because we just reload in the background anyway + symLog?.log(".onNotification(.ExchangeDeleted) ==> reloading exchanges") + Task { await reloadExchanges() } // runs on MainActor + } .task { symLog?.log(".task") await reloadExchanges()