From f708b7e0a5ad4293f1964591201bf5ceeb61b23c Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Thu, 17 Jul 2025 21:13:22 +0100 Subject: [PATCH] updated updatehost to addhost if needed --- ShhShell/Host/HostsManager.swift | 8 ++------ ShhShell/Views/Hosts/ConnectionView.swift | 3 --- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/ShhShell/Host/HostsManager.swift b/ShhShell/Host/HostsManager.swift index cce08d5..455fa22 100644 --- a/ShhShell/Host/HostsManager.swift +++ b/ShhShell/Host/HostsManager.swift @@ -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) } diff --git a/ShhShell/Views/Hosts/ConnectionView.swift b/ShhShell/Views/Hosts/ConnectionView.swift index 7db2d9b..0612042 100644 --- a/ShhShell/Views/Hosts/ConnectionView.swift +++ b/ShhShell/Views/Hosts/ConnectionView.swift @@ -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)