From abe8cc6f2a313d92f0f76b287ca4c84aa4328116 Mon Sep 17 00:00:00 2001 From: sawka Date: Tue, 20 Sep 2022 16:42:41 -0700 Subject: [PATCH] on connect message, reset session and remote information completely (clear lists) --- src/main.tsx | 2 +- src/model.ts | 12 +++++++++--- src/types.ts | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index dfa900045..d515ff9ae 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -755,7 +755,7 @@ class InfoMsg extends React.Component<{}, {}> {
alias
-
{isBlank(remote.alias) ? "-" : remote.alias}
+
{isBlank(remote.remotealias) ? "-" : remote.remotealias}
canonicalname
diff --git a/src/model.ts b/src/model.ts index 13cba520f..67d123119 100644 --- a/src/model.ts +++ b/src/model.ts @@ -5,7 +5,7 @@ import {debounce} from "throttle-debounce"; import {handleJsonFetchResponse, base64ToArray, genMergeData, genMergeSimpleData} from "./util"; import {TermWrap} from "./term"; import {v4 as uuidv4} from "uuid"; -import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, UIContextType, HistoryInfoType, HistoryQueryOpts, FeInputPacketType, TermWinSize} from "./types"; +import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, UIContextType, HistoryInfoType, HistoryQueryOpts, FeInputPacketType, TermWinSize, RemoteInputPacketType} from "./types"; import {WSControl} from "./ws"; var GlobalUser = "sawka"; @@ -1499,6 +1499,9 @@ class Model { } let update : ModelUpdateType = genUpdate; if ("sessions" in update) { + if (update.connect) { + this.sessionList.clear(); + } let oldActiveScreen = this.getActiveScreen(); genMergeData(this.sessionList, update.sessions, (s : Session) => s.sessionId, (sdata : SessionDataType) => sdata.sessionid, (sdata : SessionDataType) => new Session(sdata), (s : Session) => s.sessionIdx.get()); if (!("activesessionid" in update)) { @@ -1531,7 +1534,10 @@ class Model { this.updateWindow(update.window, false); } if ("remotes" in update) { - this.updateRemote(update.remotes); + if (update.connect) { + this.remotes.clear(); + } + this.updateRemotes(update.remotes); } if (interactive && "info" in update) { let info : InfoType = update.info; @@ -1552,7 +1558,7 @@ class Model { // console.log("run-update>", Date.now(), interactive, update); } - updateRemote(remotes : RemoteType[]) : void { + updateRemotes(remotes : RemoteType[]) : void { genMergeSimpleData(this.remotes, remotes, (r) => r.remoteid, null); } diff --git a/src/types.ts b/src/types.ts index 4a02c2789..5dbc41162 100644 --- a/src/types.ts +++ b/src/types.ts @@ -17,9 +17,12 @@ type SessionDataType = { type LineType = { sessionid : string, windowid : string, + userid : string, lineid : string, ts : number, - userid : string, + linenum : number, + linenumtemp : boolean, + linelocal : boolean, linetype : string, text : string, cmdid : string, @@ -293,4 +296,4 @@ type HistoryQueryOpts = { type UpdateMessage = PtyDataUpdateType | ModelUpdateType; -export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDonePacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType, UIContextType, HistoryInfoType, HistoryQueryOpts, WatchScreenPacketType, TermWinSize, FeInputPacketType}; +export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDonePacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType, UIContextType, HistoryInfoType, HistoryQueryOpts, WatchScreenPacketType, TermWinSize, FeInputPacketType, RemoteInputPacketType};