From 5d2a33733229cd108cd4bef422197b0f2583d758 Mon Sep 17 00:00:00 2001 From: Andrej Mihajlov Date: Tue, 15 Dec 2020 12:41:26 +0100 Subject: [PATCH] WireGuardApp: Remove 200ms delay when updating tunnel status switch Signed-off-by: Andrej Mihajlov --- .../WireGuardApp/UI/iOS/View/TunnelListCell.swift | 15 ++++++--------- .../TunnelDetailTableViewController.swift | 6 ++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift b/Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift index 9d8cc82..1a8520d 100644 --- a/Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift +++ b/Sources/WireGuardApp/UI/iOS/View/TunnelListCell.swift @@ -87,15 +87,12 @@ class TunnelListCell: UITableViewCell { reset() return } - DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(200)) { [weak statusSwitch, weak busyIndicator] in - guard let statusSwitch = statusSwitch, let busyIndicator = busyIndicator else { return } - statusSwitch.isOn = !(status == .deactivating || status == .inactive) - statusSwitch.isUserInteractionEnabled = (status == .inactive || status == .active) - if status == .inactive || status == .active { - busyIndicator.stopAnimating() - } else { - busyIndicator.startAnimating() - } + statusSwitch.isOn = !(status == .deactivating || status == .inactive) + statusSwitch.isUserInteractionEnabled = (status == .inactive || status == .active) + if status == .inactive || status == .active { + busyIndicator.stopAnimating() + } else { + busyIndicator.startAnimating() } } diff --git a/Sources/WireGuardApp/UI/iOS/ViewController/TunnelDetailTableViewController.swift b/Sources/WireGuardApp/UI/iOS/ViewController/TunnelDetailTableViewController.swift index 6d9619a..696136f 100644 --- a/Sources/WireGuardApp/UI/iOS/ViewController/TunnelDetailTableViewController.swift +++ b/Sources/WireGuardApp/UI/iOS/ViewController/TunnelDetailTableViewController.swift @@ -343,10 +343,8 @@ extension TunnelDetailTableViewController { text = tr("tunnelStatusWaiting") } cell.textLabel?.text = text - DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(200)) { [weak cell] in - cell?.switchView.isOn = !(status == .deactivating || status == .inactive) - cell?.switchView.isUserInteractionEnabled = (status == .inactive || status == .active) - } + cell.switchView.isOn = !(status == .deactivating || status == .inactive) + cell.switchView.isUserInteractionEnabled = (status == .inactive || status == .active) cell.isEnabled = status == .active || status == .inactive }