From f7ad688308f8d4563cd6bba3b1e4341b8e6a1155 Mon Sep 17 00:00:00 2001 From: Juraj Hilje Date: Wed, 11 Sep 2024 10:32:48 +0200 Subject: [PATCH] fix(widget): update ConnectionManager.swift --- IVPNClient/Managers/ConnectionManager.swift | 13 ++----------- .../Scenes/MainScreen/MainViewController.swift | 5 +++++ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/IVPNClient/Managers/ConnectionManager.swift b/IVPNClient/Managers/ConnectionManager.swift index be4ed03d2..bd52b54fc 100644 --- a/IVPNClient/Managers/ConnectionManager.swift +++ b/IVPNClient/Managers/ConnectionManager.swift @@ -96,9 +96,6 @@ class ConnectionManager { self.updateOpenVPNLogFile() self.updateWireGuardLogFile() self.reconnectAutomatically = false - if self.actionType == .connect { - self.evaluateCloseApp() - } } DispatchQueue.delay(2.5) { if UserDefaults.shared.isV2ray && !V2RayCore.shared.reconnectWithV2ray { @@ -128,10 +125,6 @@ class ConnectionManager { } } } - - if status == .disconnected && self.actionType == .disconnect { - self.evaluateCloseApp() - } completion(status) } @@ -575,12 +568,10 @@ class ConnectionManager { } } - private func evaluateCloseApp() { + func evaluateCloseApp() { if closeApp { closeApp = false - DispatchQueue.delay(1.5) { - UIControl().sendAction(#selector(NSXPCConnection.suspend), to: UIApplication.shared, for: nil) - } + UIControl().sendAction(#selector(NSXPCConnection.suspend), to: UIApplication.shared, for: nil) } } diff --git a/IVPNClient/Scenes/MainScreen/MainViewController.swift b/IVPNClient/Scenes/MainScreen/MainViewController.swift index efaa9804d..557b874d7 100644 --- a/IVPNClient/Scenes/MainScreen/MainViewController.swift +++ b/IVPNClient/Scenes/MainScreen/MainViewController.swift @@ -167,6 +167,9 @@ class MainViewController: UIViewController { if !model.isIvpnServer { Application.shared.geoLookup = model } + + WidgetCenter.shared.reloadTimelines(ofKind: "IVPNWidget") + Application.shared.connectionManager.evaluateCloseApp() case .failure: controlPanel.controlPanelView.ipv4ViewModel = ProofsViewModel(displayMode: .error) mainView.infoAlertViewModel.infoAlert = .connectionInfoFailure @@ -180,6 +183,8 @@ class MainViewController: UIViewController { case .success(let model): controlPanel.controlPanelView.ipv6ViewModel = ProofsViewModel(model: model, displayMode: .content) mainView.ipv6ViewModel = ProofsViewModel(model: model) + WidgetCenter.shared.reloadTimelines(ofKind: "IVPNWidget") + Application.shared.connectionManager.evaluateCloseApp() case .failure: controlPanel.controlPanelView.ipv6ViewModel = ProofsViewModel(displayMode: .error) mainView.ipv6ViewModel = ProofsViewModel(displayMode: .error)