From 6340a3e9ffb58a26e1c03ccd88b297d0d3af5e09 Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 15 Jul 2022 01:58:30 -0700 Subject: [PATCH] implement delete session, bug fixes --- src/main.tsx | 4 ++-- src/model.ts | 11 ++++++++--- src/ws.ts | 7 ++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index 56a3149a8..d9e160e2b 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -559,7 +559,7 @@ class ScreenTabs extends React.Component<{session : Session}, {}> { if (screen == null) { return; } - GlobalModel.activateScreen(screen.sessionId, screen.screenId); + GlobalModel.submitCommand(sprintf("/s %s", screenId)); } render() { @@ -572,7 +572,7 @@ class ScreenTabs extends React.Component<{session : Session}, {}> { return (
-
this.handleSwitchScreen(screen.screenId)}> +
this.handleSwitchScreen(screen.screenId, index+1)}> {screen.name.get()}
⌘{index+1}
diff --git a/src/model.ts b/src/model.ts index 11bb442b6..c4c25ffde 100644 --- a/src/model.ts +++ b/src/model.ts @@ -534,7 +534,7 @@ class Model { if (newScreenId == null) { return; } - this.activateScreen(activeSession.sessionId, newScreenId); + this.submitCommand(sprintf("/s %s", newScreenId)); } onDigitCmd(e : any, arg : {digit: number}, mods : KeyModsType) { @@ -558,13 +558,17 @@ class Model { } if ("sessions" in message) { let sessionUpdateMsg : SessionUpdateType = message; - console.log("update-sessions", sessionUpdateMsg.sessions); mobx.action(() => { let oldActiveScreen = this.getActiveScreen(); genMergeData(this.sessionList, sessionUpdateMsg.sessions, (s : Session) => s.sessionId, (sdata : SessionDataType) => sdata.sessionid, (sdata : SessionDataType) => new Session(sdata), (s : Session) => s.sessionIdx.get()); let newActiveScreen = this.getActiveScreen(); if (oldActiveScreen != newActiveScreen) { - this.activateScreen(newActiveScreen.sessionId, newActiveScreen.screenId, oldActiveScreen); + if (newActiveScreen == null) { + this.activateScreen(this.activeSessionId.get(), null, oldActiveScreen); + } + else { + this.activateScreen(newActiveScreen.sessionId, newActiveScreen.screenId, oldActiveScreen); + } } })(); @@ -741,6 +745,7 @@ class Model { })(); let curScreen = this.getActiveScreen(); if (curScreen == null) { + this.ws.pushMessage({type: "watchscreen", sessionid: sessionId}); return; } this.ws.pushMessage({type: "watchscreen", sessionid: curScreen.sessionId, screenid: curScreen.screenId}); diff --git a/src/ws.ts b/src/ws.ts index 17d46610a..c70cca7bf 100644 --- a/src/ws.ts +++ b/src/ws.ts @@ -117,7 +117,12 @@ class WSControl { return; } if (this.messageCallback) { - this.messageCallback(eventData); + try { + this.messageCallback(eventData); + } + catch (e) { + console.log("[error] messageCallback", e); + } } }