aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-06-13 23:01:47 +0530
committerRoopesh Chander <roop@roopc.net>2019-06-13 23:02:54 +0530
commit0a01f4cb4476a06a37ed9648463a25f9b26b51c5 (patch)
tree37a7e30c209ab5183d7b26c69dc6fd0ba9e74bed
parentmacOS: Tunnel detail: Handle deletion outside app, again (diff)
downloadwireguard-apple-0a01f4cb4476a06a37ed9648463a25f9b26b51c5.tar.xz
wireguard-apple-0a01f4cb4476a06a37ed9648463a25f9b26b51c5.zip
iOS: Importing: If tunnelsManager isn't ready yet, we should wait for it
-rw-r--r--WireGuard/WireGuard/UI/iOS/AppDelegate.swift5
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift13
2 files changed, 14 insertions, 4 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift
index 8884d44..41a136e 100644
--- a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift
+++ b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift
@@ -34,10 +34,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
- guard let tunnelsManager = mainVC?.tunnelsManager else { return true }
- TunnelImporter.importFromFile(urls: [url], into: tunnelsManager, sourceVC: mainVC, errorPresenterType: ErrorPresenter.self) {
- _ = FileManager.deleteFile(at: url)
- }
+ mainVC?.importFromDisposableFile(url: url)
return true
}
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift
index c61302b..b37a4d4 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift
@@ -109,6 +109,19 @@ extension MainViewController {
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 {