From 06f61cbc991abe0d49ba5d4c3061e856ac445a98 Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Thu, 20 Sep 2018 00:43:43 +0200 Subject: [PATCH] Make sure a scanned config is actually saved and displayed. Signed-off-by: Jason A. Donenfeld --- WireGuard/Coordinators/AppCoordinator.swift | 3 ++- WireGuard/ViewControllers/QRScanViewController.swift | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/WireGuard/Coordinators/AppCoordinator.swift b/WireGuard/Coordinators/AppCoordinator.swift index 437a30b..1ae11a5 100644 --- a/WireGuard/Coordinators/AppCoordinator.swift +++ b/WireGuard/Coordinators/AppCoordinator.swift @@ -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!) } } diff --git a/WireGuard/ViewControllers/QRScanViewController.swift b/WireGuard/ViewControllers/QRScanViewController.swift index ad57f77..811602e 100644 --- a/WireGuard/ViewControllers/QRScanViewController.swift +++ b/WireGuard/ViewControllers/QRScanViewController.swift @@ -95,13 +95,14 @@ class QRScanViewController: UIViewController { } } } - + previewLayer.frame = self.view.bounds } 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.")