diff --git a/ShhShell/SSH/SSHHandler.swift b/ShhShell/SSH/SSHHandler.swift index 6b22758..b408779 100644 --- a/ShhShell/SSH/SSHHandler.swift +++ b/ShhShell/SSH/SSHHandler.swift @@ -156,6 +156,14 @@ class SSHHandler: @unchecked Sendable, ObservableObject { } func testExec() { + defer { + Task { @MainActor in + let result = self.testSuceeded + await disconnect() + withAnimation { testSuceeded = result } + } + } + if ssh_is_connected(session) == 0 { withAnimation { testSuceeded = false } return diff --git a/ShhShell/Views/ConnectionView.swift b/ShhShell/Views/ConnectionView.swift index 559e668..4b45748 100644 --- a/ShhShell/Views/ConnectionView.swift +++ b/ShhShell/Views/ConnectionView.swift @@ -99,13 +99,6 @@ struct ConnectionView: View { handler.go() } handler.testExec() - DispatchQueue.main.asyncAfter(deadline: .now()+3) { - Task { - let result = handler.testSuceeded - await handler.disconnect() - handler.testSuceeded = result - } - } } label: { if let testResult = handler.testSuceeded { Image(systemName: testResult ? "checkmark.circle" : "xmark.circle")