Skip to content

Commit 1b8d1a3

Browse files
committed
fix: address review — simplify secretOwnerId, resolve SSH profile at list level
1 parent 5d587c2 commit 1b8d1a3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

TablePro/Core/Database/DatabaseManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ final class DatabaseManager {
458458
let profile = connection.sshProfileId.flatMap { SSHProfileStorage.shared.profile(for: $0) }
459459
let sshConfig = connection.effectiveSSHConfig(profile: profile)
460460
let isProfile = connection.sshProfileId != nil && profile != nil
461-
let secretOwnerId = connection.sshProfileId.flatMap { profile != nil ? $0 : nil } ?? connection.id
461+
let secretOwnerId = (isProfile ? connection.sshProfileId : nil) ?? connection.id
462462

463463
guard sshConfig.enabled else {
464464
return connection

TablePro/Views/Connection/WelcomeWindowView.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ struct WelcomeWindowView: View {
464464
}
465465

466466
private func connectionRow(for connection: DatabaseConnection) -> some View {
467-
ConnectionRow(connection: connection, onConnect: { connectToDatabase(connection) })
467+
let sshProfile = connection.sshProfileId.flatMap { SSHProfileStorage.shared.profile(for: $0) }
468+
return ConnectionRow(connection: connection, sshProfile: sshProfile, onConnect: { connectToDatabase(connection) })
468469
.tag(connection.id)
469470
.listRowInsets(ThemeEngine.shared.activeTheme.spacing.listRowInsets.swiftUI)
470471
.listRowSeparator(.hidden)
@@ -1011,6 +1012,7 @@ struct WelcomeWindowView: View {
10111012

10121013
private struct ConnectionRow: View {
10131014
let connection: DatabaseConnection
1015+
let sshProfile: SSHProfile?
10141016
var onConnect: (() -> Void)?
10151017

10161018
private var displayTag: ConnectionTag? {
@@ -1066,8 +1068,7 @@ private struct ConnectionRow: View {
10661068
}
10671069

10681070
private var connectionSubtitle: String {
1069-
let profile = connection.sshProfileId.flatMap { SSHProfileStorage.shared.profile(for: $0) }
1070-
let ssh = connection.effectiveSSHConfig(profile: profile)
1071+
let ssh = connection.effectiveSSHConfig(profile: sshProfile)
10711072
if ssh.enabled {
10721073
return "SSH : \(ssh.username)@\(ssh.host)"
10731074
}

0 commit comments

Comments
 (0)