mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-02-23 11:35: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) {
|
||||
_ = SiteList { (sites, _) -> Void in
|
||||
switch sites
|
||||
{
|
||||
case .some(let sites):
|
||||
if let unwrappedSites = sites?.values {
|
||||
// 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.
|
||||
Task.detached(priority: .userInitiated) {
|
||||
for site in sites.values {
|
||||
for site in unwrappedSites {
|
||||
if site.connected == true {
|
||||
// The vpn service is in charge of updating the currently connected site
|
||||
return
|
||||
|
@ -24,7 +22,7 @@ actor DNUpdater {
|
|||
}
|
||||
|
||||
}
|
||||
default: break
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,7 +42,7 @@ actor DNUpdater {
|
|||
timer.resume()
|
||||
}
|
||||
|
||||
func updateSite(site: Site, onUpdate: @escaping (Site) -> Void) {
|
||||
private func updateSite(site: Site, onUpdate: @escaping (Site) -> Void) {
|
||||
do {
|
||||
if !site.managed {
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue