Переглянути джерело

Merge pull request #1153 from deltachat/show-configure-error

show configure errors reliably
bjoern 4 роки тому
батько
коміт
639aeeedca
1 змінених файлів з 9 додано та 4 видалено
  1. 9 4
      deltachat-ios/Handler/ProgressAlertHandler.swift

+ 9 - 4
deltachat-ios/Handler/ProgressAlertHandler.swift

@@ -41,10 +41,15 @@ extension ProgressAlertHandler {
 
     func updateProgressAlert(error message: String?) {
         DispatchQueue.main.async(execute: {
-            self.progressAlert?.dismiss(animated: false)
-            let errorAlert = UIAlertController(title: String.localized("error"), message: message, preferredStyle: .alert)
-            errorAlert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: nil))
-            self.present(errorAlert, animated: true, completion: nil)
+            // CAVE: show the new alert in the dismiss-done-handler of the previous one -
+            // otherwise we get the error "Attempt to present <UIAlertController: ...> while a presentation is in progress."
+            // and the error won't be shown.
+            // (when animated is true, that works also sequentially, however better not rely on that, also we do not want an animation here)
+            self.progressAlert?.dismiss(animated: false) {
+                let errorAlert = UIAlertController(title: String.localized("error"), message: message, preferredStyle: .alert)
+                errorAlert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: nil))
+                self.present(errorAlert, animated: true, completion: nil)
+            }
         })
     }