From ecc4c6f87eaf27ede7d993b750dd5c9b3647ecbf Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 9 Apr 2021 10:03:04 +0200 Subject: [PATCH] Update VPN toggle if disabling while "Inactive" Due to trusted network. --- Passepartout/App/iOS/CHANGELOG.md | 2 ++ Passepartout/App/macOS/CHANGELOG.md | 1 + Passepartout/App/macOS/Menu/StatusMenu.swift | 8 ++++++-- .../Scenes/Service/ServiceViewController.swift | 15 ++++++++------- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Passepartout/App/iOS/CHANGELOG.md b/Passepartout/App/iOS/CHANGELOG.md index dcc9cbfd..8dcc3784 100644 --- a/Passepartout/App/iOS/CHANGELOG.md +++ b/Passepartout/App/iOS/CHANGELOG.md @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + ## 1.15.1 (2021-02-14) ### Fixed diff --git a/Passepartout/App/macOS/CHANGELOG.md b/Passepartout/App/macOS/CHANGELOG.md index 7a2b74e7..015826fd 100644 --- a/Passepartout/App/macOS/CHANGELOG.md +++ b/Passepartout/App/macOS/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Prevent ineffective editing of trusted network SSID. +- VPN not being disabled when "Inactive" due to trusted network. ## 1.15.1 (2021-02-14) diff --git a/Passepartout/App/macOS/Menu/StatusMenu.swift b/Passepartout/App/macOS/Menu/StatusMenu.swift index c6c43b57..15f3a5fc 100644 --- a/Passepartout/App/macOS/Menu/StatusMenu.swift +++ b/Passepartout/App/macOS/Menu/StatusMenu.swift @@ -421,11 +421,15 @@ class StatusMenu: NSObject { } @objc private func enableVPN() { - vpn.reconnect(completionHandler: nil) + vpn.reconnect { _ in + self.reloadVpnStatus() + } } @objc private func disableVPN() { - vpn.disconnect(completionHandler: nil) + vpn.disconnect { _ in + self.reloadVpnStatus() + } } @objc private func reconnectVPN() { diff --git a/Passepartout/App/macOS/Scenes/Service/ServiceViewController.swift b/Passepartout/App/macOS/Scenes/Service/ServiceViewController.swift index 07417ec3..a4c63cb6 100644 --- a/Passepartout/App/macOS/Scenes/Service/ServiceViewController.swift +++ b/Passepartout/App/macOS/Scenes/Service/ServiceViewController.swift @@ -189,19 +189,20 @@ class ServiceViewController: NSViewController { status = .disconnected } service.activateProfile(profile) - reloadVpnStatus() - switch status { - case .disconnected: + if !vpn.isEnabled { guard !service.needsCredentials(for: uncheckedProfile) else { isPendingConnection = true perform(segue: StoryboardSegue.Service.accountSegueIdentifier) return } - vpn.reconnect(completionHandler: nil) - - default: - vpn.disconnect(completionHandler: nil) + vpn.reconnect { _ in + self.reloadVpnStatus() + } + } else { + vpn.disconnect { _ in + self.reloadVpnStatus() + } } }