Use an if-let to unwrap sites optional value

This commit is contained in:
Caleb Jasik 2025-02-11 15:57:25 -06:00
parent 06ed3dfaaa
commit a64f1226cd
No known key found for this signature in database

View file

@ -8,13 +8,11 @@ actor DNUpdater {
func updateAll(onUpdate: @escaping (Site) -> Void) { func updateAll(onUpdate: @escaping (Site) -> Void) {
_ = SiteList { (sites, _) -> Void in _ = SiteList { (sites, _) -> Void in
switch sites if let unwrappedSites = sites?.values {
{
case .some(let sites):
// NEVPN seems to force us onto the main thread and we are about to make network calls that // NEVPN seems to force us onto the main thread and we are about to make network calls that
// could block for a while. Push ourselves onto another thread to avoid blocking the UI. // could block for a while. Push ourselves onto another thread to avoid blocking the UI.
Task.detached(priority: .userInitiated) { Task.detached(priority: .userInitiated) {
for site in sites.values { for site in unwrappedSites {
if site.connected == true { if site.connected == true {
// The vpn service is in charge of updating the currently connected site // The vpn service is in charge of updating the currently connected site
return return
@ -24,7 +22,7 @@ actor DNUpdater {
} }
} }
default: break
} }
} }
@ -44,7 +42,7 @@ actor DNUpdater {
timer.resume() timer.resume()
} }
func updateSite(site: Site, onUpdate: @escaping (Site) -> Void) { private func updateSite(site: Site, onUpdate: @escaping (Site) -> Void) {
do { do {
if !site.managed { if !site.managed {
return return