Make sure a scanned config is actually saved and displayed.

This commit is contained in:
Jeroen Leenarts 2018-09-20 00:43:43 +02:00
parent 2d35068f4d
commit 72465bd341
2 changed files with 4 additions and 2 deletions

View File

@ -521,7 +521,8 @@ extension AppCoordinator: TunnelConfigurationTableViewControllerDelegate {
extension AppCoordinator: QRScanViewControllerDelegate {
func didSave(tunnel: Tunnel, qrScanViewController: QRScanViewController) {
showTunnelConfigurationViewController(tunnel: tunnel, context: tunnel.managedObjectContext!)
qrScanViewController.navigationController?.popViewController(animated: true)
showTunnelInfoViewController(tunnel: tunnel, context: tunnel.managedObjectContext!)
}
}

View File

@ -102,6 +102,7 @@ class QRScanViewController: UIViewController {
func scanDidComplete(withCode code: String) {
do {
let tunnel = try Tunnel.fromConfig(code, context: viewContext)
try viewContext.save()
delegate?.didSave(tunnel: tunnel, qrScanViewController: self)
} catch {
scanDidEncounterError(title: "Invalid Code", message: "The scanned code is not a valid WireGuard config file.")