From 2028a98784878de41d3a72fe01322feb962b8fc0 Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 24 Aug 2022 02:12:28 -0700 Subject: [PATCH] remoteinstance naming change --- src/model.ts | 73 ++++++++++++++++++++++++---------------------------- src/types.ts | 13 +++++++--- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/model.ts b/src/model.ts index f9890d368..e7e41f3ff 100644 --- a/src/model.ts +++ b/src/model.ts @@ -4,7 +4,7 @@ import {boundMethod} from "autobind-decorator"; 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, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType, SessionUpdateType, WindowUpdateType, UpdateMessage, LineCmdUpdateType, InfoType, CmdLineUpdateType} from "./types"; +import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType, SessionUpdateType, WindowUpdateType, UpdateMessage, LineCmdUpdateType, InfoType, CmdLineUpdateType} from "./types"; import {WSControl} from "./ws"; var GlobalUser = "sawka"; @@ -17,6 +17,22 @@ function isBlank(s : string) { return (s == null || s == ""); } +function remotePtrToString(rptr : RemotePtrType) : string { + if (rptr == null || isBlank(rptr.remoteid)) { + return null; + } + if (isBlank(rptr.owneruserid) && isBlank(rptr.name)) { + return rptr.remoteid; + } + if (!isBlank(rptr.owneruserid) && isBlank(rptr.name)) { + return sprintf("@%s:%s", rptr.owneruserid, rptr.remoteid) + } + if (isBlank(rptr.owneruserid) && !isBlank(rptr.name)) { + return sprintf("%s:%s", rptr.remoteid, rptr.name) + } + return sprintf("@%s:%s:%s", rptr.owneruserid, rptr.remoteid, rptr.name) +} + type KeyModsType = { meta? : boolean, ctrl? : boolean, @@ -275,12 +291,11 @@ class ScreenWindow { class Window { sessionId : string; windowId : string; - curRemote : OV = mobx.observable.box(null); + curRemote : OV = mobx.observable.box(null); loaded : OV = mobx.observable.box(false); loadError : OV = mobx.observable.box(null); lines : OArr = mobx.observable.array([], {deep: false}); cmds : Record = {}; - remoteInstances : OArr = mobx.observable.array([]); constructor(sessionId : string, windowId : string) { this.sessionId = sessionId; @@ -289,7 +304,7 @@ class Window { updateWindow(win : WindowDataType, load : boolean) { mobx.action(() => { - if (!isBlank(win.curremote)) { + if (win.curremote != null && win.curremote.remoteid != "") { this.curRemote.set(win.curremote); } if (load) { @@ -301,7 +316,6 @@ class Window { for (let i=0; i r.riid, null); })(); } @@ -339,36 +353,12 @@ class Window { } getCurRemoteInstance() : RemoteInstanceType { - let rname = this.curRemote.get(); - if (rname == null) { + let session = GlobalModel.getSessionById(this.sessionId); + let rptr = this.curRemote.get(); + if (rptr == null) { return null; } - let sessionScope = false; - if (rname.startsWith("^")) { - rname = rname.substr(1); - sessionScope = true; - } - if (sessionScope) { - let session = GlobalModel.getSessionById(this.sessionId); - let rdata = session.getRemoteInstance(rname); - return rdata; - } - return this.getRemoteInstance(rname); - } - - getRemoteInstance(rname : string) : RemoteInstanceType { - for (let i=0; i r.riid, null); })(); } @@ -537,17 +528,21 @@ class Session { return null; } - getRemoteInstance(rname : string) : RemoteInstanceType { + getRemoteInstance(windowId : string, rptr : RemotePtrType) : RemoteInstanceType { + if (rptr.name.startsWith("*")) { + windowId = ""; + } for (let i=0; i