QR code: Minor refactoring
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
@@ -96,13 +96,13 @@ class QRScanViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func scanDidComplete(withCode code: String) {
|
func scanDidComplete(withCode code: String) {
|
||||||
do {
|
let scannedTunnelConfiguration = try? WgQuickConfigFileParser.parse(code, name: "Scanned")
|
||||||
let tunnelConfiguration = try WgQuickConfigFileParser.parse(code, name: "Scanned")
|
guard let tunnelConfiguration = scannedTunnelConfiguration else {
|
||||||
delegate?.scannedQRCode(tunnelConfiguration: tunnelConfiguration, qrScanViewController: self)
|
|
||||||
dismiss(animated: true, completion: nil)
|
|
||||||
} catch {
|
|
||||||
scanDidEncounterError(title: "Invalid Code", message: "The scanned code is not a valid WireGuard config file.")
|
scanDidEncounterError(title: "Invalid Code", message: "The scanned code is not a valid WireGuard config file.")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
delegate?.scannedQRCode(tunnelConfiguration: tunnelConfiguration, qrScanViewController: self)
|
||||||
|
dismiss(animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func scanDidEncounterError(title: String, message: String) {
|
func scanDidEncounterError(title: String, message: String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user