updated updatehost to addhost if needed

This commit is contained in:
neon443
2025-07-17 21:13:22 +01:00
parent d4120e5352
commit f708b7e0a5
2 changed files with 2 additions and 9 deletions

View File

@@ -198,6 +198,8 @@ class HostsManager: ObservableObject, @unchecked Sendable {
updateHostWithNewID.id = oldID
withAnimation { hosts[index] = updateHostWithNewID }
saveHosts()
} else {
withAnimation { hosts.append(updatedHost) }slack
}
}
@@ -232,12 +234,6 @@ class HostsManager: ObservableObject, @unchecked Sendable {
}
}
func addHostIfNeeded(_ hostToAdd: Host) {
if !hosts.contains(hostToAdd) {
hosts.append(hostToAdd)
}
}
func removeHost(_ host: Host) {
if let index = hosts.firstIndex(where: { $0.id == host.id }) {
let _ = withAnimation { hosts.remove(at: index) }

View File

@@ -120,9 +120,6 @@ struct ConnectionView: View {
.onDisappear {
hostsManager.updateHost(handler.host)
}
.onAppear {
hostsManager.addHostIfNeeded(handler.host)
}
.alert("Hostkey changed", isPresented: $hostKeyChangedAlert) {
Button("Accept New Hostkey", role: .destructive) {
hostsManager.updateHost(handler.host)