Issue #3: Added Settings class to store selected BlocklistOption. Update system DoH settings, when user selects another blocklist.

This commit is contained in:
Benjamin Erhart 2026-04-15 13:40:29 +02:00
parent 807176f0b5
commit 6cbad66a87
2 changed files with 39 additions and 10 deletions

View file

@ -12,21 +12,19 @@ import OSLog
class ViewModel: NSObject, ObservableObject {
// TODO: Store this in UserDefaults
@Published
var blocklist: BlocklistOption = .secure
var blocklist: BlocklistOption = .secure {
didSet {
Settings.blocklist = blocklist
toggleDns()
}
}
// TODO: Store this in UserDefaults
@Published
var isDnsEnabled = false {
didSet {
if !isProgrammaticChange {
toggleDns()
}
else {
// Reset, so next one is recognized as coming from the user again.
isProgrammaticChange = false
}
toggleDns()
}
}
@ -39,6 +37,13 @@ class ViewModel: NSObject, ObservableObject {
func toggleDns() {
guard !isProgrammaticChange else {
// Reset, so next one is recognized as coming from the user again.
isProgrammaticChange = false
return
}
Task {
if isDnsEnabled {
manager.dnsSettings = blocklist.settings