Issue #2: Use ViewModel to evaluate server to use for counting number of blocked domains.

This commit is contained in:
Benjamin Erhart 2026-04-14 18:21:00 +02:00
parent 6b253a6843
commit 634b4d26e8

View file

@ -4,7 +4,10 @@ import Foundation
struct BlockedCount: View { struct BlockedCount: View {
@State private var txtRecord: String = "..." @EnvironmentObject
private var viewModel: ViewModel
@State private var txtRecord: String = ""
private static let startIndex = 44 private static let startIndex = 44
@ -44,7 +47,7 @@ struct BlockedCount: View {
} }
func fetchTXTRecord() { func fetchTXTRecord() {
let dohURL = URL(string: "https://dns.sr2.uk/dns-query?dns=DoQBAAABAAAAAAAABXN0YXRzB2ludmFsaWQAABAAAQ")! let dohURL = URL(string: "https://\(viewModel.blocklist.server)/dns-query?dns=DoQBAAABAAAAAAAABXN0YXRzB2ludmFsaWQAABAAAQ")!
let request = URLRequest(url: dohURL) let request = URLRequest(url: dohURL)
@ -68,4 +71,5 @@ struct BlockedCount: View {
#Preview { #Preview {
BlockedCount() BlockedCount()
.environmentObject(ViewModel())
} }