diff --git a/IVPNClient/Managers/ConnectionManager.swift b/IVPNClient/Managers/ConnectionManager.swift index be4ed03d..bd52b54f 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 80e94f7f..db4f524d 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)