Unblock the UI when trying to update dn managed sites (#125)
This commit is contained in:
parent
cfca253ec1
commit
450e7c714c
|
@ -6,6 +6,9 @@ class DNUpdater {
|
||||||
|
|
||||||
func updateAll(onUpdate: @escaping (Site) -> ()) {
|
func updateAll(onUpdate: @escaping (Site) -> ()) {
|
||||||
_ = SiteList{ (sites, _) -> () in
|
_ = SiteList{ (sites, _) -> () in
|
||||||
|
// 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) {
|
||||||
sites?.values.forEach { site in
|
sites?.values.forEach { site in
|
||||||
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
|
||||||
|
@ -16,6 +19,7 @@ class DNUpdater {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func updateAllLoop(onUpdate: @escaping (Site) -> ()) {
|
func updateAllLoop(onUpdate: @escaping (Site) -> ()) {
|
||||||
timer.eventHandler = {
|
timer.eventHandler = {
|
||||||
|
|
Loading…
Reference in New Issue