From a44f3cab839dcdfa9e8b2b63d5ba8412ccbd373b Mon Sep 17 00:00:00 2001 From: Yannick Spreen Date: Wed, 5 May 2021 08:37:59 +0200 Subject: [PATCH] Fix typos; Add table reload. (#18) --- DGCAWallet/Protocols/CertViewerDelegate.swift | 2 +- DGCAWallet/Services/GatewayConnection.swift | 6 +++--- DGCAWallet/ViewControllers/CertificateViewer.swift | 4 +++- DGCAWallet/ViewControllers/List.swift | 7 ++++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/DGCAWallet/Protocols/CertViewerDelegate.swift b/DGCAWallet/Protocols/CertViewerDelegate.swift index 2e2576d..085e752 100644 --- a/DGCAWallet/Protocols/CertViewerDelegate.swift +++ b/DGCAWallet/Protocols/CertViewerDelegate.swift @@ -27,5 +27,5 @@ import Foundation protocol CertViewerDelegate { - func childDismissed() + func childDismissed(_ newCertAdded: Bool) } diff --git a/DGCAWallet/Services/GatewayConnection.swift b/DGCAWallet/Services/GatewayConnection.swift index 6a25f79..3b22357 100644 --- a/DGCAWallet/Services/GatewayConnection.swift +++ b/DGCAWallet/Services/GatewayConnection.swift @@ -56,14 +56,14 @@ struct GatewayConnection { let keyParam: [String: Any] = [ "type": "EC256", - "value": "pubkey", + "value": pubKey, ] let param: [String: Any] = [ "DGCI": cert.uvci, "TANHash": tanHash, "certhash": certHash, "publicKey": keyParam, - "signature": sign.base64EncodedData(), + "signature": sign.base64EncodedString(), ] AF.request(serverURI + claimEndpoint, method: .get, parameters: param, encoding: JSONEncoding.default, headers: nil, interceptor: nil, requestModifier: nil).response { guard @@ -71,7 +71,7 @@ struct GatewayConnection { let status = $0.response?.statusCode, status == 204 else { - completion?(false) + completion?(true) return } completion?(true) diff --git a/DGCAWallet/ViewControllers/CertificateViewer.swift b/DGCAWallet/ViewControllers/CertificateViewer.swift index 52a1008..5c565e5 100644 --- a/DGCAWallet/ViewControllers/CertificateViewer.swift +++ b/DGCAWallet/ViewControllers/CertificateViewer.swift @@ -67,11 +67,12 @@ class CertificateViewerVC: UIViewController { return } + var newCertAdded = false override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) Brightness.reset() - childDismissedDelegate?.childDismissed() + childDismissedDelegate?.childDismissed(newCertAdded) } @IBAction @@ -97,6 +98,7 @@ class CertificateViewerVC: UIViewController { return } LocalData.add(cert) + self?.newCertAdded = true self?.showAlert( title: "Success", subtitle: "Certificate was saved to wallet!" diff --git a/DGCAWallet/ViewControllers/List.swift b/DGCAWallet/ViewControllers/List.swift index 8389032..04a203f 100644 --- a/DGCAWallet/ViewControllers/List.swift +++ b/DGCAWallet/ViewControllers/List.swift @@ -46,7 +46,6 @@ class ListVC: UIViewController { table.dataSource = self table.delegate = self - reloadTable() } @IBAction @@ -105,7 +104,10 @@ class ListVC: UIViewController { } extension ListVC: CertViewerDelegate { - func childDismissed() { + func childDismissed(_ newCertAdded: Bool) { + if newCertAdded { + reloadTable() + } presentingViewer = nil } } @@ -114,7 +116,6 @@ extension ListVC: ScanVCDelegate { func hCertScanned(_ cert: HCert) { newHCertScanned = cert DispatchQueue.main.async { [weak self] in - self?.reloadTable() self?.navigationController?.popViewController(animated: true) } }