[F] Fix alarm completion order

This commit is contained in:
Hykilpikonna
2021-01-24 19:31:44 -05:00
parent e84fb87cd0
commit 58a7fe300c
2 changed files with 9 additions and 3 deletions
+3
View File
@@ -259,6 +259,9 @@ class FamilyCreateJoinVC: UIViewController
sendReq(APIs.familyCreate, title: "Creating...", params: ["name": name, "pin": pin])
{
self.msg("Created!", "Your family ID is \($0.fid)")
{
self.dismiss()
}
}
}
}
+6 -3
View File
@@ -122,13 +122,13 @@ extension UIViewController
- Parameter okayable: Whether the alert can be okayed
*/
@discardableResult
func alert(_ title: String, _ message: String, okayable: Bool = false) -> UIAlertController
func alert(_ title: String, _ message: String, okayable: Bool = false, _ completion: (() -> Void)? = nil) -> UIAlertController
{
// Create alert
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
// Add okay button if it's okayable
if okayable { alert.addAction(UIAlertAction(title: "OK", style: .default)) }
if okayable { alert.addAction(UIAlertAction(title: "OK", style: .default) { it in if let c = completion { c() } }) }
// Display alert
self.present(alert, animated: true, completion: nil)
@@ -137,7 +137,10 @@ extension UIViewController
/// A message is an okayable alert
@discardableResult
func msg(_ title: String, _ message: String) -> UIAlertController { alert(title, message, okayable: true) }
func msg(_ title: String, _ message: String, _ completion: (() -> Void)? = nil) -> UIAlertController
{
alert(title, message, okayable: true, completion)
}
/// More convenient dismiss function
func dismiss(_ completion: (() -> Void)? = nil) { ui { self.dismiss(animated: false, completion: completion) } }