Skip to content

Commit ead29d1

Browse files
authored
Refactor SignerView for improved readability
1 parent aad7f2d commit ead29d1

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

Sources/prostore/views/SignerView.swift

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,32 +131,30 @@ struct SignerView: View {
131131
return
132132
}
133133
let certDir = CertificateFileManager.shared.certificatesDirectory.appendingPathComponent(selectedFolder)
134-
do {
135-
if let nameData = try? Data(contentsOf: certDir.appendingPathComponent("name.txt")),
136-
let name = String(data: nameData, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines),
137-
!name.isEmpty {
138-
selectedCertificateName = name
139-
} else {
140-
selectedCertificateName = "Custom Certificate"
141-
}
142-
let provURL = certDir.appendingPathComponent("profile.mobileprovision")
143-
if let expiry = ProStoreTools.getExpirationDate(provURL: provURL) {
144-
let now = Date()
145-
let components = Calendar.current.dateComponents([.day], from: now, to: expiry)
146-
let days = components.day ?? 0
147-
switch days {
134+
if let nameData = try? Data(contentsOf: certDir.appendingPathComponent("name.txt")),
135+
let name = String(data: nameData, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines),
136+
!name.isEmpty {
137+
selectedCertificateName = name
138+
} else {
139+
selectedCertificateName = "Custom Certificate"
140+
}
141+
let provURL = certDir.appendingPathComponent("profile.mobileprovision")
142+
if let expiry = ProStoreTools.getExpirationDate(provURL: provURL) {
143+
let now = Date()
144+
let components = Calendar.current.dateComponents([.day], from: now, to: expiry)
145+
let days = components.day ?? 0
146+
switch days {
148147
case ..<0, 0:
149148
expireStatus = "Expired"
150149
case 1...30:
151150
expireStatus = "Expiring Soon"
152151
default:
153152
expireStatus = "Valid"
154-
}
155-
} else {
156-
expireStatus = "Unknown"
157153
}
158-
hasSelectedCertificate = true
154+
} else {
155+
expireStatus = "Unknown"
159156
}
157+
hasSelectedCertificate = true
160158
}
161159

162160
func runSign() {
@@ -281,3 +279,4 @@ struct SignerView: View {
281279
}
282280

283281
}
282+

0 commit comments

Comments
 (0)