feat: update block count when blocklist changes
This commit is contained in:
parent
822202e37d
commit
26fd94dbe3
1 changed files with 5 additions and 1 deletions
|
|
@ -23,6 +23,9 @@ struct BlockedCount: View {
|
|||
.onAppear {
|
||||
fetchTXTRecord()
|
||||
}
|
||||
.onChange(of: viewModel.blocklist) { _ in
|
||||
fetchTXTRecord()
|
||||
}
|
||||
}
|
||||
|
||||
func parseResponse(data: Data) -> String? {
|
||||
|
|
@ -48,9 +51,10 @@ struct BlockedCount: View {
|
|||
|
||||
func fetchTXTRecord() {
|
||||
let dohURL = URL(string: "https://\(viewModel.blocklist.server)/dns-query?dns=DoQBAAABAAAAAAAABXN0YXRzB2ludmFsaWQAABAAAQ")!
|
||||
|
||||
let request = URLRequest(url: dohURL)
|
||||
|
||||
txtRecord = "…"
|
||||
|
||||
Task {
|
||||
do {
|
||||
let (data, _) = try await URLSession.shared.data(for: request)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue