mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
updated updatehost to addhost if needed
This commit is contained in:
@@ -198,6 +198,8 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
|||||||
updateHostWithNewID.id = oldID
|
updateHostWithNewID.id = oldID
|
||||||
withAnimation { hosts[index] = updateHostWithNewID }
|
withAnimation { hosts[index] = updateHostWithNewID }
|
||||||
saveHosts()
|
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) {
|
func removeHost(_ host: Host) {
|
||||||
if let index = hosts.firstIndex(where: { $0.id == host.id }) {
|
if let index = hosts.firstIndex(where: { $0.id == host.id }) {
|
||||||
let _ = withAnimation { hosts.remove(at: index) }
|
let _ = withAnimation { hosts.remove(at: index) }
|
||||||
|
|||||||
@@ -120,9 +120,6 @@ struct ConnectionView: View {
|
|||||||
.onDisappear {
|
.onDisappear {
|
||||||
hostsManager.updateHost(handler.host)
|
hostsManager.updateHost(handler.host)
|
||||||
}
|
}
|
||||||
.onAppear {
|
|
||||||
hostsManager.addHostIfNeeded(handler.host)
|
|
||||||
}
|
|
||||||
.alert("Hostkey changed", isPresented: $hostKeyChangedAlert) {
|
.alert("Hostkey changed", isPresented: $hostKeyChangedAlert) {
|
||||||
Button("Accept New Hostkey", role: .destructive) {
|
Button("Accept New Hostkey", role: .destructive) {
|
||||||
hostsManager.updateHost(handler.host)
|
hostsManager.updateHost(handler.host)
|
||||||
|
|||||||
Reference in New Issue
Block a user