WireGuardApp: Remove 200ms delay when updating tunnel status switch

Signed-off-by: Andrej Mihajlov <and@mullvad.net>
This commit is contained in:
Andrej Mihajlov 2020-12-15 12:41:26 +01:00 committed by Jason A. Donenfeld
parent facf776602
commit 5d2a337332
2 changed files with 8 additions and 13 deletions

View File

@ -87,15 +87,12 @@ class TunnelListCell: UITableViewCell {
reset() reset()
return return
} }
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(200)) { [weak statusSwitch, weak busyIndicator] in statusSwitch.isOn = !(status == .deactivating || status == .inactive)
guard let statusSwitch = statusSwitch, let busyIndicator = busyIndicator else { return } statusSwitch.isUserInteractionEnabled = (status == .inactive || status == .active)
statusSwitch.isOn = !(status == .deactivating || status == .inactive) if status == .inactive || status == .active {
statusSwitch.isUserInteractionEnabled = (status == .inactive || status == .active) busyIndicator.stopAnimating()
if status == .inactive || status == .active { } else {
busyIndicator.stopAnimating() busyIndicator.startAnimating()
} else {
busyIndicator.startAnimating()
}
} }
} }

View File

@ -343,10 +343,8 @@ extension TunnelDetailTableViewController {
text = tr("tunnelStatusWaiting") text = tr("tunnelStatusWaiting")
} }
cell.textLabel?.text = text cell.textLabel?.text = text
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(200)) { [weak cell] in cell.switchView.isOn = !(status == .deactivating || status == .inactive)
cell?.switchView.isOn = !(status == .deactivating || status == .inactive) cell.switchView.isUserInteractionEnabled = (status == .inactive || status == .active)
cell?.switchView.isUserInteractionEnabled = (status == .inactive || status == .active)
}
cell.isEnabled = status == .active || status == .inactive cell.isEnabled = status == .active || status == .inactive
} }