implement delete session, bug fixes

This commit is contained in:
sawka 2022-07-15 01:58:30 -07:00
parent 057637660c
commit 6340a3e9ff
3 changed files with 16 additions and 6 deletions

View File

@ -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 (
<div className="screen-tabs">
<For each="screen" index="index" of={session.screens}>
<div key={screen.screenId} className={cn("screen-tab", {"is-active": session.activeScreenId.get() == screen.screenId})} onClick={() => this.handleSwitchScreen(screen.screenId)}>
<div key={screen.screenId} className={cn("screen-tab", {"is-active": session.activeScreenId.get() == screen.screenId})} onClick={() => this.handleSwitchScreen(screen.screenId, index+1)}>
{screen.name.get()}
<If condition={index+1 <= 9}>
<div className="tab-index">&#x2318;{index+1}</div>

View File

@ -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});

View File

@ -117,7 +117,12 @@ class WSControl {
return;
}
if (this.messageCallback) {
this.messageCallback(eventData);
try {
this.messageCallback(eventData);
}
catch (e) {
console.log("[error] messageCallback", e);
}
}
}