From e29dd20722ce6762258064538351be32c4b2436f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Heidekr=C3=BCger?= Date: Fri, 5 Apr 2024 10:30:48 +0200 Subject: [PATCH] Use SettingsStore for querying the comment style in SecretDetailView Fixes: https://github.com/maxgoedjen/secretive/pull/536#discussion_r1509655340 --- Sources/Secretive/Views/SecretDetailView.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/Secretive/Views/SecretDetailView.swift b/Sources/Secretive/Views/SecretDetailView.swift index 319d668..a0f8ebb 100644 --- a/Sources/Secretive/Views/SecretDetailView.swift +++ b/Sources/Secretive/Views/SecretDetailView.swift @@ -4,7 +4,7 @@ import SecretKit struct SecretDetailView: 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)) @@ -43,11 +43,12 @@ struct SecretDetailView: 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)") } } }