Browse Source

Merge pull request #762 from deltachat/maybe-network-on-reconnect

trigger maybeNetwork() on getting to foreground
bjoern 5 years ago
parent
commit
19f3c5fc0c
1 changed files with 5 additions and 8 deletions
  1. 5 8
      deltachat-ios/AppDelegate.swift

+ 5 - 8
deltachat-ios/AppDelegate.swift

@@ -53,14 +53,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
 
         reachability.whenReachable = { reachability in
         reachability.whenReachable = { reachability in
             logger.info("network: reachable", reachability.connection.description)
             logger.info("network: reachable", reachability.connection.description)
-
-            // call dc_maybe_network() from a worker thread.
-            // normally, dc_maybe_network() can be called uncoditionally,
-            // however, in fact, it may halt things for some seconds.
-            // this pr is a workaround that make things usable for now.
-            DispatchQueue.global(qos: .background).async {
-               self.dcContext.maybeNetwork()
-           }
+            self.dcContext.maybeNetwork()
         }
         }
 
 
         reachability.whenUnreachable = { _ in
         reachability.whenUnreachable = { _ in
@@ -110,6 +103,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         logger.info("---- foreground ----")
         logger.info("---- foreground ----")
         appIsInForeground = true
         appIsInForeground = true
         startThreads()
         startThreads()
+
+        if reachability.connection != .none {
+            self.dcContext.maybeNetwork()
+        }
     }
     }
 
 
     func applicationDidEnterBackground(_: UIApplication) {
     func applicationDidEnterBackground(_: UIApplication) {