- Notifications
You must be signed in to change notification settings - Fork3
chore: set 'stop VPN on quit' setting to true by default#155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -55,7 +55,8 @@ class AppState: ObservableObject { | ||
} | ||
} | ||
// Defaults to `true` | ||
@Published var stopVPNOnQuit: Bool = UserDefaults.standard.optionalBool(forKey: Keys.stopVPNOnQuit) ?? true { | ||
didSet { | ||
guard persistent else { return } | ||
UserDefaults.standard.set(stopVPNOnQuit, forKey: Keys.stopVPNOnQuit) | ||
@@ -239,3 +240,14 @@ extension LiteralHeader { | ||
.init(name: name, value: value) | ||
} | ||
} | ||
extension UserDefaults { | ||
// Unlike the exisitng `bool(forKey:)` method which returns `false` for both | ||
// missing values this method can return `nil`. | ||
func optionalBool(forKey key: String) -> Bool? { | ||
guard object(forKey: key) != nil else { | ||
return nil | ||
} | ||
return bool(forKey: key) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I don't understand why this API doesn't already just return a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||
} | ||
} |
Uh oh!
There was an error while loading.Please reload this page.