mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-02-23 19:45:26 +00:00
Use an if-let to unwrap sites
optional value
This commit is contained in:
parent
06ed3dfaaa
commit
a64f1226cd
1 changed files with 4 additions and 6 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue