Reuse delay() function as global macro

This commit is contained in:
Davide De Rosa 2019-10-27 22:03:26 +01:00
parent 5f3ebfd9fe
commit aea5dc330c
2 changed files with 7 additions and 1 deletions

View File

@ -61,3 +61,9 @@ extension UIColor {
self.init(red: r, green: g, blue: b, alpha: alpha)
}
}
func delay(_ block: @escaping () -> Void) {
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {
block()
}
}

View File

@ -273,7 +273,7 @@ class ServiceViewController: UIViewController, StrongTableHost {
guard error == nil else {
// XXX: delay to avoid weird toggle state
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {
delay {
cell.setOn(false, animated: true)
if error as? ApplicationError == .externalResources {
self.requireDownload()