feat: socket error handling

* create a new session when failed to connect to socket
* reset termnal on connect
This commit is contained in:
wancat authored and Annie Huang committed 2023-11-12 21:23:12 +08:00
1 parent 2639c0ddda
commit ed14491cfc
4 files changed
+39 -31

No files matched your search

+10 -4
View File
@@ -48,13 +48,14 @@ class SessionManager {
return this.session.value
}
setSession(session) {
async setSession(session) {
this.session.value = session
this.graph.value = new FileGraph(session.graph)
this.hints.value = session.hints
this.status.value = session.status
this.term.clear()
this.socket.connect(session)
this.term.reset()
await this.socket.connect(session)
this.term.focus()
}
handleGraphUpdate(event) {
@@ -92,7 +93,12 @@ class SessionManager {
})
const session = res.data
console.log(session)
this.setSession(session)
try {
await this.setSession(session)
} catch (err) {
console.log(err)
this.createSession().catch(console.error)
}
}
}