addedfunctions to check state

large code cleanup thanks to this
This commit is contained in:
neon443 committed 2025-06-25 12:40:16 +01:00
1 parent 66547dc58e
commit 46ba88aacb
3 files changed
+23 -11

No files matched your search

+5 -7
View File
@@ -20,8 +20,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
@Published var title: String = ""
@Published var state: SSHState = .idle
var connected: Bool {
return !(state == .idle || state == .connecting)
// return state == .authorized || state == .shellOpen || state == .authorizing
return checkConnected(state)
}
// @Published var connected: Bool = false
// @Published var authorized: Bool = false
@@ -57,6 +56,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
func go() {
guard !connected else {
withAnimation { state = .idle }
Task {
await disconnect()
}
@@ -130,8 +130,6 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
func disconnect() async {
await MainActor.run {
withAnimation { state = .idle }
// withAnimation { connected = false }
// withAnimation { authorized = false }
withAnimation { testSuceeded = nil }
}
@@ -171,7 +169,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
}
}
if state == .authorized {} else {
if !checkAuth(state) {
go()
}
@@ -180,7 +178,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
return
}
guard state == .authorized else {
guard checkAuth(state) else {
withAnimation { testSuceeded = false }
return
}
@@ -378,7 +376,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
status = ssh_channel_request_shell(self.channel)
guard status == SSH_OK else { return }
withAnimation { state = .shellOpen }
}
func readFromChannel() -> String? {
+12
View File
@@ -14,3 +14,15 @@ enum SSHState {
case authorized
case shellOpen
}
func checkConnected(_ state: SSHState) -> Bool {
return !(state == .idle || state == .connecting)
}
func checkAuth(_ state: SSHState) -> Bool {
return state == .authorized || state == .shellOpen
}
func checkShell(_ state: SSHState) -> Bool {
return state == .shellOpen
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.