Skip to content

Commit

Permalink
Clean up Home VC.
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen committed Apr 27, 2021
1 parent a5ba567 commit f4a95be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
11 changes: 11 additions & 0 deletions DGCAVerifier/Models/LocalData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,15 @@ struct LocalData: Codable {
}

static let storage = SecureStorage<LocalData>()

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()
}
}
}
5 changes: 0 additions & 5 deletions DGCAVerifier/Services/SecureStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ struct SecureStorage<T: Codable> {
completion?(nil)
return
}
// print(path, "read:", String(data: decrypted, encoding: .utf8)!)
completion?(data)
}
}
Expand All @@ -89,7 +88,6 @@ struct SecureStorage<T: Codable> {
completion?(false)
return
}
// print(path, "write:", String(data: data, encoding: .utf8)!)
Enclave.sign(data: encrypted, with: key) { signature, err in
guard
let signature = signature,
Expand Down Expand Up @@ -120,9 +118,6 @@ struct SecureStorage<T: Codable> {
else {
return nil
}
// print("read")
// print(String(data: rawData, encoding: .utf8)!)
// print(result)
return (result.data, result.signature)
}
}
9 changes: 2 additions & 7 deletions DGCAVerifier/ViewControllers/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit f4a95be

Please sign in to comment.