iOS: Importing: If tunnelsManager isn't ready yet, we should wait for it
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
4ef7afe3ca
commit
b286ede3c6
|
@ -34,10 +34,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
|
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
|
||||||
guard let tunnelsManager = mainVC?.tunnelsManager else { return true }
|
mainVC?.importFromDisposableFile(url: url)
|
||||||
TunnelImporter.importFromFile(urls: [url], into: tunnelsManager, sourceVC: mainVC, errorPresenterType: ErrorPresenter.self) {
|
|
||||||
_ = FileManager.deleteFile(at: url)
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,19 @@ extension MainViewController {
|
||||||
onTunnelsManagerReady = showTunnelDetailBlock
|
onTunnelsManagerReady = showTunnelDetailBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func importFromDisposableFile(url: URL) {
|
||||||
|
let importFromFileBlock: (TunnelsManager) -> Void = { [weak self] tunnelsManager in
|
||||||
|
TunnelImporter.importFromFile(urls: [url], into: tunnelsManager, sourceVC: self, errorPresenterType: ErrorPresenter.self) {
|
||||||
|
_ = FileManager.deleteFile(at: url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let tunnelsManager = tunnelsManager {
|
||||||
|
importFromFileBlock(tunnelsManager)
|
||||||
|
} else {
|
||||||
|
onTunnelsManagerReady = importFromFileBlock
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MainViewController: UISplitViewControllerDelegate {
|
extension MainViewController: UISplitViewControllerDelegate {
|
||||||
|
|
Loading…
Reference in New Issue