]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
State restoration: Don't create duplicate mainVC and tunnelsListVC
authorRoopesh Chander <roop@roopc.net>
Tue, 11 Dec 2018 12:18:34 +0000 (17:48 +0530)
committerRoopesh Chander <roop@roopc.net>
Tue, 11 Dec 2018 12:22:54 +0000 (17:52 +0530)
This creates a duplicate tunnels manager, leading to problems tracking
tunnel statuses.

To reproduce the bug that this commit fixes, you can do the following:
1. Remove all tunnels
2. Run in Xcode
3. Import zip with ~10 tunnels
4. Stop app in Xcode
5. Run in Xcode
6. Turn on 1st tunnel, after it's on, turn off
Turn on 2nd tunnel, after it's on, turn off
...
After 6-8 tunnels, the spinner doesn't show up, indicating that the
status is not being tracked.

Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/UI/iOS/AppDelegate.swift

index 3116f7a2a0196159f31e9a9fe78efc1bf7bb06b8..5dca2ad637078bc50d1ad95eec35b616e49037e2 100644 (file)
@@ -52,11 +52,7 @@ extension AppDelegate {
                      viewControllerWithRestorationIdentifierPath identifierComponents: [String],
                      coder: NSCoder) -> UIViewController? {
         guard let vcIdentifier = identifierComponents.last else { return nil }
-        if (vcIdentifier == "MainVC") {
-            return MainViewController()
-        } else if (vcIdentifier == "TunnelsListVC") {
-            return TunnelsListTableViewController()
-        } else if (vcIdentifier.hasPrefix("TunnelDetailVC:")) {
+        if (vcIdentifier.hasPrefix("TunnelDetailVC:")) {
             let tunnelName = String(vcIdentifier.suffix(vcIdentifier.count - "TunnelDetailVC:".count))
             if let tunnelsManager = mainVC?.tunnelsManager {
                 if let tunnel = tunnelsManager.tunnel(named: tunnelName) {
@@ -66,7 +62,6 @@ extension AppDelegate {
                 // Show it when tunnelsManager is available
                 mainVC?.showTunnelDetailForTunnel(named: tunnelName, animated: false)
             }
-
         }
         return nil
     }