From e1ff0341150ea1d8815ae471239abae0f6840040 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Fri, 22 Jan 2021 17:46:04 -0500 Subject: [PATCH] [O] Encapsulate ui{} inside alarm.dismiss{} --- ProjectClock/AccountViewController.swift | 19 ++++++++----------- ProjectClock/Utils.swift | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ProjectClock/AccountViewController.swift b/ProjectClock/AccountViewController.swift index 282ffaf..e26527a 100644 --- a/ProjectClock/AccountViewController.swift +++ b/ProjectClock/AccountViewController.swift @@ -92,23 +92,20 @@ class LoginVC: UIViewController localStorage["pass"] = pass.sha256 localStorage["id"] = $0 - ui + a.dismiss { - a.dismiss - { - // Send feedback - if login { self.msg("Login success!", "Now you can use account features, yay!") } - else { self.msg("Registration success!", "Now you have an account, yay!") } - - // Hide registration and show account detail view - AccountViewController.this.login() - } + // Send feedback + if login { self.msg("Login success!", "Now you can use account features, yay!") } + else { self.msg("Registration success!", "Now you have an account, yay!") } + + // Hide registration and show account detail view + AccountViewController.this.login() } } err: { print($0) - ui { a.dismiss { self.msg("An error occurred", "Maybe the server is on fire, just wait a few hours.") } } + a.dismiss { self.msg("An error occurred", "Maybe the server is on fire, just wait a few hours.") } } } diff --git a/ProjectClock/Utils.swift b/ProjectClock/Utils.swift index 8cee80d..2940048 100644 --- a/ProjectClock/Utils.swift +++ b/ProjectClock/Utils.swift @@ -139,7 +139,7 @@ extension UIViewController func msg(_ title: String, _ message: String) -> UIAlertController { alert(title, message, okayable: true) } /// More convenient dismiss function - func dismiss(_ completion: (() -> Void)? = nil) { dismiss(animated: false, completion: completion) } + func dismiss(_ completion: (() -> Void)? = nil) { ui { dismiss(animated: false, completion: completion) } } }