Skip to content

Commit b7c9f58

Browse files
committed
add stop vpn on quit setting
1 parent f617f6f commit b7c9f58

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

Coder Desktop/Coder Desktop/Coder_DesktopApp.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
4848
}
4949

5050
// MUST eventually call `NSApp.reply(toApplicationShouldTerminate: true)`
51+
// or return `.terminateNow`
5152
func applicationShouldTerminate(_: NSApplication) -> NSApplication.TerminateReply {
53+
if !settings.stopVPNOnQuit { return .terminateNow }
5254
Task {
5355
await vpn.stop()
5456
NSApp.reply(toApplicationShouldTerminate: true)

Coder Desktop/Coder Desktop/State.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ class Settings: ObservableObject {
104104
}
105105
}
106106

107+
@AppStorage(Keys.stopVPNOnQuit) var stopVPNOnQuit = true
108+
107109
init(store: UserDefaults = .standard) {
108110
self.store = store
109111
_literalHeaders = Published(
@@ -116,6 +118,7 @@ class Settings: ObservableObject {
116118
enum Keys {
117119
static let useLiteralHeaders = "UseLiteralHeaders"
118120
static let literalHeaders = "LiteralHeaders"
121+
static let stopVPNOnQuit = "StopVPNOnQuit"
119122
}
120123
}
121124

Coder Desktop/Coder Desktop/Views/Settings/GeneralTab.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ import LaunchAtLogin
22
import SwiftUI
33

44
struct GeneralTab: View {
5+
@EnvironmentObject var settings: Settings
56
var body: some View {
67
Form {
78
Section {
89
LaunchAtLogin.Toggle("Launch at Login")
910
}
11+
Section {
12+
Toggle(isOn: $settings.stopVPNOnQuit) {
13+
Text("Stop VPN on Quit")
14+
}
15+
}
1016
}.formStyle(.grouped)
1117
}
1218
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy