瀏覽代碼

clearer error message on login error if no internet connection available #503

cyberta 5 年之前
父節點
當前提交
e29d20bf3a

+ 3 - 0
deltachat-ios/AppDelegate.swift

@@ -22,6 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     var locationManager: LocationManager!
     private var backgroundTask: UIBackgroundTaskIdentifier = .invalid
     var reachability = Reachability()!
+    var hasNetwork = false
     var window: UIWindow?
     var state = ApplicationState.stopped
 
@@ -226,6 +227,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         switch reachability.connection {
         case .wifi, .cellular:
             logger.info("network: reachable", reachability.connection.description)
+            hasNetwork = true
 
             // call dc_maybe_network() from a worker thread.
             // normally, dc_maybe_network() can be called uncoditionally,
@@ -236,6 +238,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             }
         case .none:
             logger.info("network: not reachable")
+            hasNetwork = false
         }
     }
 

+ 5 - 1
deltachat-ios/Controller/AccountSetupController.swift

@@ -658,7 +658,11 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
             notification in
             if let ui = notification.userInfo {
                 if ui["error"] as! Bool {
-                    self.updateProgressAlert(error: ui["errorMessage"] as? String)
+                    var errorMessage = ui["errorMessage"] as? String
+                    if let appDelegate = UIApplication.shared.delegate as? AppDelegate, !appDelegate.hasNetwork {
+                        errorMessage = String.localized("login_error_no_internet_connection")
+                    }
+                    self.updateProgressAlert(error: errorMessage)
                 } else if ui["done"] as! Bool {
                     self.updateProgressAlertSuccess(completion: self.handleLoginSuccess)
                 } else {

+ 1 - 0
deltachat-ios/en.lproj/Localizable.strings

@@ -650,3 +650,4 @@
 "import_contacts_message" = "To chat with contacts from your device open Settings and enable Contacts.";
 "stop_sharing_location" = "Stop sharing location";
 "a11y_voice_message_hint_ios" = "After recording double-tap to send. To discard the recording scrub left-right with two fingers.";
+"login_error_no_internet_connection" = "No internet connection, can\'t log in to your server.";

+ 1 - 0
tools/untranslated.xml

@@ -6,4 +6,5 @@
     <string name="import_contacts_message">To chat with contacts from your device open Settings and enable Contacts.</string>
     <string name="stop_sharing_location">Stop sharing location</string>
     <string name="a11y_voice_message_hint_ios">After recording double-tap to send. To discard the recording scrub left-right with two fingers.</string>
+    <string name="login_error_no_internet_connection">No internet connection, can\'t log in to your server.</string>
 </resources>