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) { if (screen == null) {
return; return;
} }
GlobalModel.activateScreen(screen.sessionId, screen.screenId); GlobalModel.submitCommand(sprintf("/s %s", screenId));
} }
render() { render() {
@ -572,7 +572,7 @@ class ScreenTabs extends React.Component<{session : Session}, {}> {
return ( return (
<div className="screen-tabs"> <div className="screen-tabs">
<For each="screen" index="index" of={session.screens}> <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()} {screen.name.get()}
<If condition={index+1 <= 9}> <If condition={index+1 <= 9}>
<div className="tab-index">&#x2318;{index+1}</div> <div className="tab-index">&#x2318;{index+1}</div>

View File

@ -534,7 +534,7 @@ class Model {
if (newScreenId == null) { if (newScreenId == null) {
return; return;
} }
this.activateScreen(activeSession.sessionId, newScreenId); this.submitCommand(sprintf("/s %s", newScreenId));
} }
onDigitCmd(e : any, arg : {digit: number}, mods : KeyModsType) { onDigitCmd(e : any, arg : {digit: number}, mods : KeyModsType) {
@ -558,14 +558,18 @@ class Model {
} }
if ("sessions" in message) { if ("sessions" in message) {
let sessionUpdateMsg : SessionUpdateType = message; let sessionUpdateMsg : SessionUpdateType = message;
console.log("update-sessions", sessionUpdateMsg.sessions);
mobx.action(() => { mobx.action(() => {
let oldActiveScreen = this.getActiveScreen(); 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()); 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(); let newActiveScreen = this.getActiveScreen();
if (oldActiveScreen != newActiveScreen) { if (oldActiveScreen != newActiveScreen) {
if (newActiveScreen == null) {
this.activateScreen(this.activeSessionId.get(), null, oldActiveScreen);
}
else {
this.activateScreen(newActiveScreen.sessionId, newActiveScreen.screenId, oldActiveScreen); this.activateScreen(newActiveScreen.sessionId, newActiveScreen.screenId, oldActiveScreen);
} }
}
})(); })();
} }
@ -741,6 +745,7 @@ class Model {
})(); })();
let curScreen = this.getActiveScreen(); let curScreen = this.getActiveScreen();
if (curScreen == null) { if (curScreen == null) {
this.ws.pushMessage({type: "watchscreen", sessionid: sessionId});
return; return;
} }
this.ws.pushMessage({type: "watchscreen", sessionid: curScreen.sessionId, screenid: curScreen.screenId}); this.ws.pushMessage({type: "watchscreen", sessionid: curScreen.sessionId, screenid: curScreen.screenId});

View File

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