State restoration: Don't create duplicate mainVC and tunnelsListVC
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>
This commit is contained in:
parent
1ded24f0e0
commit
bde984625c
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue