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)