Skip to content

Commit

Permalink
Use SettingsStore for querying the comment style in SecretDetailView
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhdk committed Apr 9, 2024
1 parent bd51af7 commit 834458f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Sources/Secretive/Views/SecretDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SecretKit
struct SecretDetailView<SecretType: Secret>: View {

@State var secret: SecretType
@AppStorage("com.maxgoedjen.Secretive.commentStyle") var style: CommentStyle = .keyAndHost
@EnvironmentObject private var settingsStore: SettingsStore

private let keyWriter = OpenSSHKeyWriter()
private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: NSHomeDirectory().replacingOccurrences(of: Bundle.main.hostBundleID, with: Bundle.main.agentBundleID))
Expand Down Expand Up @@ -43,11 +43,12 @@ struct SecretDetailView<SecretType: Secret>: View {
}

var keyString: String {
var style: CommentStyle = CommentStyle(rawValue: settingsStore["com.maxgoedjen.Secretive.commentStyle"] ?? CommentStyle.keyAndHost.rawValue)!
switch style {
case CommentStyle.none:
keyWriter.openSSHString(secret: secret, comment: "")
default:
keyWriter.openSSHString(secret: secret, comment: "\(dashedKeyName)@\(dashedHostName)")
case .none:
return keyWriter.openSSHString(secret: secret, comment: "")
case .keyAndHost:
return keyWriter.openSSHString(secret: secret, comment: "\(dashedKeyName)@\(dashedHostName)")
}
}
}
Expand Down

0 comments on commit 834458f

Please sign in to comment.