diff --git a/DGCAVerifier/Models/LocalData.swift b/DGCAVerifier/Models/LocalData.swift index 459e450..a4b239f 100644 --- a/DGCAVerifier/Models/LocalData.swift +++ b/DGCAVerifier/Models/LocalData.swift @@ -59,4 +59,15 @@ struct LocalData: Codable { } static let storage = SecureStorage() + + static func initialize(completion: @escaping () -> Void) { + storage.loadOverride(fallback: LocalData.sharedInstance) { success in + guard let result = success else { + return + } + print("loaded \(result.encodedPublicKeys.count) certs from ", LocalData.storage.path ?? .init(fileURLWithPath: "/")) + LocalData.sharedInstance = result + completion() + } + } } diff --git a/DGCAVerifier/Services/SecureStorage.swift b/DGCAVerifier/Services/SecureStorage.swift index 54f8cc0..343376c 100644 --- a/DGCAVerifier/Services/SecureStorage.swift +++ b/DGCAVerifier/Services/SecureStorage.swift @@ -75,7 +75,6 @@ struct SecureStorage { completion?(nil) return } -// print(path, "read:", String(data: decrypted, encoding: .utf8)!) completion?(data) } } @@ -89,7 +88,6 @@ struct SecureStorage { completion?(false) return } -// print(path, "write:", String(data: data, encoding: .utf8)!) Enclave.sign(data: encrypted, with: key) { signature, err in guard let signature = signature, @@ -120,9 +118,6 @@ struct SecureStorage { else { return nil } -// print("read") -// print(String(data: rawData, encoding: .utf8)!) -// print(result) return (result.data, result.signature) } } diff --git a/DGCAVerifier/ViewControllers/Home.swift b/DGCAVerifier/ViewControllers/Home.swift index 8865980..c462709 100644 --- a/DGCAVerifier/ViewControllers/Home.swift +++ b/DGCAVerifier/ViewControllers/Home.swift @@ -34,13 +34,8 @@ class HomeVC: UIViewController { super.viewDidAppear(animated) GatewayConnection.timer?.invalidate() - LocalData.storage.loadOverride(fallback: LocalData.sharedInstance) { [weak self] success in - guard let result = success else { - return - } -// print("loaded:", result) - LocalData.sharedInstance = result - DispatchQueue.main.async { + LocalData.initialize { + DispatchQueue.main.async { [weak self] in self?.performSegue(withIdentifier: "scanner", sender: self) } }