taler-ios

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

commit 051ab5f507fd13b643fcbc086b98385f904d0606
parent 1290711a449e9061bdd29dc793ce27aa4e960bca
Author: Marc Stibane <marc@taler.net>
Date:   Thu, 20 Aug 2026 19:10:43 +0200

AI: NWPathMonitor cannot be restarted after cancel()

Diffstat:
MTalerWallet1/Controllers/Controller.swift | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift @@ -170,6 +170,7 @@ class Controller: ObservableObject { var progressToken: String? = nil private let monitor = NWPathMonitor() + private var isMonitoringConnection = false private var diagnosticModeObservation: NSKeyValueObservation? #if OIM @@ -271,7 +272,16 @@ class Controller: ObservableObject { } } + // NWPathMonitor cannot be restarted after `cancel()` - so we just keep it running forever +// func stopCheckingConnection() { +// self.logger.log("Stop monitoring internet connection") +// isMonitoringConnection = false +// monitor.cancel() +// } + func checkInternetConnection() { + guard !isMonitoringConnection else { return } // don't try to start NWPathMonitor a second time + isMonitoringConnection = true monitor.pathUpdateHandler = { path in let status = switch path.status { case .satisfied: "active" @@ -286,7 +296,6 @@ class Controller: ObservableObject { await WalletModel.shared.hintNetworkAvailabilityT(false) } } else { - self.stopCheckingConnection() self.isConnected = true Task.detached { await WalletModel.shared.hintNetworkAvailabilityT(true) @@ -298,10 +307,6 @@ class Controller: ObservableObject { let queue = DispatchQueue(label: "InternetMonitor") monitor.start(queue: queue) } - func stopCheckingConnection() { - self.logger.log("Stop monitoring internet connection") - monitor.cancel() - } func printFonts() { for family in UIFont.familyNames {