diff --git a/DGCAWallet/Components/WalletCell.swift b/DGCAWallet/Components/WalletCell.swift index 1236a6f..1dd23f3 100644 --- a/DGCAWallet/Components/WalletCell.swift +++ b/DGCAWallet/Components/WalletCell.swift @@ -35,12 +35,13 @@ class WalletCell: UITableViewCell { func setupCell(_ dated: DatedCertString) { guard let cert = dated.cert else { return } - typeLabel.text = cert.certTypeString nameLabel.text = cert.fullName dateLabel.text = String(format: "Scanned %@".localized, dated.date.localDateString) guard let cert = dated.cert else { return } - revocationLabel.isHidden = cert.isRevoked ?? true - revocationLabel.text = cert.isRevoked == true ? "Certificate revoked" : "" + if let isRevoked = cert.isRevoked { + revocationLabel.isHidden = !isRevoked + } + revocationLabel.text = "Certificate revoked" } } diff --git a/DGCAWallet/Models/DataStorageManagement/DataStuctures.swift b/DGCAWallet/Models/DataStorageManagement/DataStuctures.swift index a36398b..c3882dd 100644 --- a/DGCAWallet/Models/DataStorageManagement/DataStuctures.swift +++ b/DGCAWallet/Models/DataStorageManagement/DataStuctures.swift @@ -24,55 +24,58 @@ // // Created by Igor Khomiak on 11/3/21. // - + import Foundation import SwiftDGC import CertLogic class DatedCertString: Codable { - var isSelected: Bool = false - let date: Date - let certString: String - let storedTAN: String? - var cert: HCert? { - return try? HCert(from: certString) - } - - - init(date: Date, certString: String, storedTAN: String?) { - self.date = date - self.certString = certString - self.storedTAN = storedTAN - } + var isSelected: Bool = false + let date: Date + let certString: String + let storedTAN: String? + var cert: HCert? { + return try? HCert(from: certString) + } + + init(date: Date, certString: String, storedTAN: String?, isRevoked: Bool?) { + self.date = date + if isRevoked != nil && isRevoked == true { + self.certString = "x" + certString + } else { + self.certString = certString + } + self.storedTAN = storedTAN + } } class LocalData: Codable { - var encodedPublicKeys = [String: [String]]() - var certStrings = [DatedCertString]() - - var countryCodes = [CountryModel]() - var valueSets = [ValueSet]() - var rules = [Rule]() - - var resumeToken: String? - var lastFetchRaw: Date? - var lastFetch: Date { - get { - lastFetchRaw ?? Date.distantPast - } - set { - lastFetchRaw = newValue - } - } - var config = Config.load() - var lastLaunchedAppVersion = "0.0" + var encodedPublicKeys = [String: [String]]() + var certStrings = [DatedCertString]() + + var countryCodes = [CountryModel]() + var valueSets = [ValueSet]() + var rules = [Rule]() + + var resumeToken: String? + var lastFetchRaw: Date? + var lastFetch: Date { + get { + lastFetchRaw ?? Date.distantPast + } + set { + lastFetchRaw = newValue + } + } + var config = Config.load() + var lastLaunchedAppVersion = "0.0" } class ImageDataStorage: Codable { - var images = [SavedImage]() + var images = [SavedImage]() } class PdfDataStorage: Codable { - var pdfs = [SavedPDF]() + var pdfs = [SavedPDF]() } diff --git a/DGCAWallet/Models/DataStorageManagement/LocalDataManager.swift b/DGCAWallet/Models/DataStorageManagement/LocalDataManager.swift index 4262c10..d6e1ffe 100644 --- a/DGCAWallet/Models/DataStorageManagement/LocalDataManager.swift +++ b/DGCAWallet/Models/DataStorageManagement/LocalDataManager.swift @@ -46,7 +46,7 @@ class LocalDataManager { } func add(_ cert: HCert, with tan: String?, completion: @escaping DataCompletionHandler) { - localData.certStrings.append(DatedCertString(date: Date(), certString: cert.fullPayloadString, storedTAN: tan)) + localData.certStrings.append(DatedCertString(date: Date(), certString: cert.fullPayloadString, storedTAN: tan, isRevoked: cert.isRevoked)) storage.save(localData, completion: completion) } diff --git a/DGCAWallet/Services/GatewayConnection.swift b/DGCAWallet/Services/GatewayConnection.swift index 90e4c1e..abe87d1 100644 --- a/DGCAWallet/Services/GatewayConnection.swift +++ b/DGCAWallet/Services/GatewayConnection.swift @@ -141,9 +141,9 @@ class GatewayConnection: ContextConnection { let revokedHashes = response as [String] for revokedHash in revokedHashes { certs.forEach { date, cert in - if revokedHash.elementsEqual(cert.uvciHash!.toHexString()) || - revokedHash.elementsEqual(cert.signatureHash!.toHexString()) || - revokedHash.elementsEqual(cert.countryCodeUvciHash!.toHexString()) { + if revokedHash.elementsEqual(cert.uvciHash![0.. - +