Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit dee8155

Browse files
authored
Automate certificate validation and refine details layout in OfficialCertificatesView
1 parent cda27c6 commit dee8155

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

Sources/prosign/views/CertificateView.swift

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,14 @@ struct OfficialCertificatesView: View {
124124
if let release = selectedRelease {
125125
Section("Details") {
126126
Text("Tag: \(release.tagName)")
127+
if !statusMessage.isEmpty {
128+
Text(statusMessage)
129+
.foregroundColor(statusColor)
130+
}
127131
Text("Published: \(dateFormatter.string(from: isoDate(string: release.publishedAt)))")
128-
}
129-
}
130-
Section {
131-
Button("Check Certificate") {
132-
checkCertificate()
133-
}
134-
.disabled(selectedRelease == nil || isChecking)
135-
if !statusMessage.isEmpty {
136-
Text(statusMessage)
137-
.foregroundColor(statusColor)
138-
}
139-
if let expiry = expiry {
140-
expiryDisplay(for: expiry)
132+
if let exp = expiry {
133+
expiryDisplay(for: exp)
134+
}
141135
}
142136
}
143137
Section {
@@ -159,9 +153,26 @@ struct OfficialCertificatesView: View {
159153
.onAppear {
160154
fetchReleases()
161155
}
156+
.onChange(of: selectedRelease) { oldValue, newValue in
157+
if newValue != nil && !isChecking {
158+
clearCertificateData()
159+
checkCertificate()
160+
} else if oldValue != nil && newValue == nil {
161+
clearCertificateData()
162+
}
163+
}
162164
}
163165
}
164166

167+
private func clearCertificateData() {
168+
statusMessage = ""
169+
expiry = nil
170+
p12Data = nil
171+
provData = nil
172+
password = nil
173+
displayName = ""
174+
}
175+
165176
private func expiryDisplay(for expiry: Date) -> some View {
166177
let now = Date()
167178
let components = Calendar.current.dateComponents([.day], from: now, to: expiry)
@@ -294,7 +305,7 @@ struct OfficialCertificatesView: View {
294305
let p12DataLocal = try Data(contentsOf: p12Url)
295306
let provDataLocal = try Data(contentsOf: provUrl)
296307
var successPw: String?
297-
for pwCandidate in ["Hydrogen", "nocturnacerts", "Sideloadingdotorg"] {
308+
for pwCandidate in ["Hydrogen", "Sideloadingdotorg", "nocturnacerts"] {
298309
switch CertificatesManager.check(p12Data: p12DataLocal, password: pwCandidate, mobileProvisionData: provDataLocal) {
299310
case .success(.success):
300311
successPw = pwCandidate

0 commit comments

Comments
 (0)