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)") } } }