From e8494b92965b1a4d80ce8850b0b366b4f9e5756f Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Wed, 25 Jun 2025 12:00:49 +0100 Subject: [PATCH] improve disconnection on testexec - it disconnects right after testing exec! - it saves the result of tesetexec even tho disconnect clears it - moved the logic into sshhandler --- ShhShell/SSH/SSHHandler.swift | 8 ++++++++ ShhShell/Views/ConnectionView.swift | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) 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")