@@ -5,9 +5,11 @@ import Foundation
55public struct AppDetailView : View {
66 let app : AltApp
77 @StateObject private var downloadManager = DownloadSignManager ( )
8- @State private var showCertError = false
98 @Environment ( \. dismiss) private var dismiss
10-
9+
10+ // NEW: alert state for missing certificate
11+ @State private var showCertError = false
12+
1113 private var latestVersion : AppVersion ? {
1214 app. versions? . first
1315 }
@@ -191,10 +193,6 @@ public struct AppDetailView: View {
191193 }
192194 . frame ( maxWidth: . infinity, alignment: . leading)
193195 . padding ( )
194- . alert ( " Please select a certificate first! " , isPresented: $showCertError) {
195- Button ( " OK " , role: . cancel) { }
196- }
197-
198196 }
199197
200198 // Floating Download Button
@@ -204,6 +202,7 @@ public struct AppDetailView: View {
204202 HStack {
205203 Spacer ( )
206204 Button ( action: {
205+ // CHECK: show error immediately if no cert selected
207206 if downloadManager. selectedCertificate == nil {
208207 showCertError = true
209208 return
@@ -289,6 +288,11 @@ public struct AppDetailView: View {
289288 . foregroundColor ( . red)
290289 } else if app. downloadURL != nil {
291290 Button ( action: {
291+ // Also check here if you want consistent behaviour
292+ if downloadManager. selectedCertificate == nil {
293+ showCertError = true
294+ return
295+ }
292296 downloadManager. downloadAndSign ( app: app)
293297 } ) {
294298 HStack ( spacing: 4 ) {
@@ -299,6 +303,10 @@ public struct AppDetailView: View {
299303 }
300304 }
301305 }
306+ // ALERT: shown immediately when no certificate selected
307+ . alert ( " Please select a certificate first! " , isPresented: $showCertError) {
308+ Button ( " OK " , role: . cancel) { }
309+ }
302310 . animation ( . easeInOut( duration: 0.3 ) , value: downloadManager. isProcessing)
303311 . animation ( . easeInOut( duration: 0.3 ) , value: downloadManager. showSuccess)
304312 }
0 commit comments