mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-13 19:10:39 +00:00
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: a87eadea19
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
42 lines
1.5 KiB
Swift
42 lines
1.5 KiB
Swift
import SwiftUI
|
|
|
|
struct GatewayTrustPromptAlert: ViewModifier {
|
|
@Environment(GatewayConnectionController.self) private var gatewayController: GatewayConnectionController
|
|
|
|
private var promptBinding: Binding<GatewayConnectionController.TrustPrompt?> {
|
|
Binding(
|
|
get: { self.gatewayController.pendingTrustPrompt },
|
|
set: { _ in
|
|
// Keep pending trust state until explicit user action.
|
|
// `alert(item:)` may set the binding to nil during dismissal, which can race with
|
|
// the button handler and cause accept to no-op.
|
|
})
|
|
}
|
|
|
|
func body(content: Content) -> some View {
|
|
content.alert(item: self.promptBinding) { prompt in
|
|
Alert(
|
|
title: Text("Trust this gateway?"),
|
|
message: Text(
|
|
"""
|
|
First-time TLS connection.
|
|
|
|
Verify this SHA-256 fingerprint out-of-band before trusting:
|
|
\(prompt.fingerprintSha256)
|
|
"""),
|
|
primaryButton: .cancel(Text("Cancel")) {
|
|
self.gatewayController.declinePendingTrustPrompt()
|
|
},
|
|
secondaryButton: .default(Text("Trust and connect")) {
|
|
Task { await self.gatewayController.acceptPendingTrustPrompt() }
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func gatewayTrustPromptAlert() -> some View {
|
|
self.modifier(GatewayTrustPromptAlert())
|
|
}
|
|
}
|