fix typescript warnings

This commit is contained in:
sawka 2022-08-25 12:12:56 -07:00
parent 35179e06ec
commit e677455419
3 changed files with 39 additions and 51 deletions

View File

@ -8,7 +8,7 @@ import dayjs from 'dayjs'
import {If, For, When, Otherwise, Choose} from "tsx-control-statements/components";
import cn from "classnames"
import {TermWrap} from "./term";
import type {SessionDataType, LineType, CmdDataType, RemoteType, RemoteStateType, RemoteInstanceType} from "./types";
import type {SessionDataType, LineType, CmdDataType, RemoteType, RemoteStateType, RemoteInstanceType, RemotePtrType} from "./types";
import localizedFormat from 'dayjs/plugin/localizedFormat';
import {GlobalModel, GlobalInput, Session, Cmd, Window, Screen, ScreenWindow, riToRPtr} from "./model";
@ -275,7 +275,7 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width
}
@boundMethod
clickTermBlock(e : any, handler : string) {
clickTermBlock(e : any) {
let {sw, line} = this.props;
let model = GlobalModel;
let termWrap = sw.getTermWrap(line.cmdid);
@ -415,7 +415,7 @@ class TextAreaInput extends React.Component<{}, {}> {
if (e.code == "Enter") {
e.preventDefault();
if (!ctrlMod) {
setTimeout(() => this.doSubmitCmd(), 0);
setTimeout(() => GlobalModel.inputModel.uiSubmitCommand(), 0);
return;
}
e.target.setRangeText("\n", e.target.selectionStart, e.target.selectionEnd, "end");
@ -466,17 +466,6 @@ class TextAreaInput extends React.Component<{}, {}> {
})();
}
@boundMethod
doSubmitCmd() {
let model = GlobalModel;
let inputModel = model.inputModel;
let commandStr = inputModel.getCurLine();
let hitem = {cmdtext: commandStr};
inputModel.clearCurLine();
GlobalModel.clearInfoMsg(true);
model.submitRawCommand(commandStr, true);
}
render() {
let model = GlobalModel;
let inputModel = model.inputModel;
@ -585,7 +574,7 @@ class CmdInput extends React.Component<{}, {}> {
<TextAreaInput/>
</div>
<div className="control cmd-exec">
<div onClick={this.doSubmitCmd} className="button">
<div onClick={GlobalModel.inputModel.uiSubmitCommand} className="button">
<span className="icon">
<i className="fa fa-rocket"/>
</span>

View File

@ -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, RemotePtrType, 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, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType} from "./types";
import {WSControl} from "./ws";
var GlobalUser = "sawka";
@ -37,7 +37,7 @@ function riToRPtr(ri : RemoteInstanceType) : RemotePtrType {
if (ri == null) {
return null;
}
return {ownerid: ri.ownerid, remoteid: ri.remoteid, name: ri.name};
return {ownerid: ri.remoteownerid, remoteid: ri.remoteid, name: ri.name};
}
type KeyModsType = {
@ -576,6 +576,16 @@ class InputModel {
})();
}
@boundMethod
uiSubmitCommand() : void {
mobx.action(() => {
let commandStr = this.getCurLine();
this.clearCurLine();
GlobalModel.clearInfoMsg(true);
GlobalModel.submitRawCommand(commandStr, true);
})();
}
setCurLine(val : string) {
let hidx = this.historyIndex.get();
mobx.action(() => {
@ -952,20 +962,21 @@ class Model {
return this.ws.open.get();
}
runUpdate(update : UpdateMessage, interactive : boolean) {
if ("ptydata64" in update) {
let ptyMsg : PtyDataUpdateType = update;
runUpdate(genUpdate : UpdateMessage, interactive : boolean) {
if ("ptydata64" in genUpdate) {
let ptyMsg : PtyDataUpdateType = genUpdate;
let activeScreen = this.getActiveScreen();
if (!activeScreen || activeScreen.sessionId != ptyMsg.sessionid) {
return;
}
activeScreen.updatePtyData(ptyMsg);
return;
}
let update : ModelUpdateType = genUpdate;
if ("sessions" in update) {
let sessionUpdateMsg : SessionUpdateType = update;
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());
genMergeData(this.sessionList, update.sessions, (s : Session) => s.sessionId, (sdata : SessionDataType) => sdata.sessionid, (sdata : SessionDataType) => new Session(sdata), (s : Session) => s.sessionIdx.get());
if (update.activesessionid) {
this.activateSession(update.activesessionid);
}
@ -983,28 +994,25 @@ class Model {
})();
}
if ("line" in update) {
let lineMsg : LineCmdUpdateType = update;
if (lineMsg.line != null) {
this.addLineCmd(lineMsg.line, lineMsg.cmd, interactive);
if (update.line != null) {
this.addLineCmd(update.line, update.cmd, interactive);
}
else if (lineMsg.line == null && lineMsg.cmd != null) {
this.updateCmd(lineMsg.cmd);
else if (update.line == null && update.cmd != null) {
this.updateCmd(update.cmd);
}
}
else if ("cmd" in update) {
this.updateCmd(update.cmd);
}
if ("window" in update) {
let winMsg : WindowUpdateType = update;
this.updateWindow(winMsg.window, false);
this.updateWindow(update.window, false);
}
if ("info" in update) {
let info : InfoType = update.info;
this.flashInfoMsg(info, info.timeoutms);
}
if ("cmdline" in update) {
let cmdline : CmdLineUpdateType = update.cmdline;
this.inputModel.updateCmdLine(cmdline);
this.inputModel.updateCmdLine(update.cmdline);
}
// console.log("run-update>", Date.now(), interactive, update);
}

View File

@ -196,15 +196,15 @@ type PtyDataUpdateType = {
ptydatalen : number,
};
type SessionUpdateType = {
sessions : SessionDataType[],
type ModelUpdateType = {
sessions? : SessionDataType[],
activesessionid? : string,
};
type LineCmdUpdateType = {
line : LineType,
cmd : CmdDataType,
remove : boolean,
window? : WindowDataType,
line? : LineType,
cmd? : CmdDataType,
info? : InfoType,
cmdline? : CmdLineUpdateType,
remote? : RemoteType,
};
type CmdLineUpdateType = {
@ -212,17 +212,6 @@ type CmdLineUpdateType = {
insertpos : number,
};
type InfoUpdateType = {
cmdline : CmdLineUpdateType,
info : InfoType,
};
type UpdateMessage = PtyDataUpdateType | SessionUpdateType | LineCmdUpdateType | InfoUpdateType;
type WindowUpdateType = {
window: WindowDataType,
}
type InfoType = {
infotitle? : string,
infomsg? : string,
@ -233,4 +222,6 @@ type InfoType = {
timeoutms? : number,
};
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDonePacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType, PtyDataUpdateType, SessionUpdateType, WindowUpdateType, UpdateMessage, LineCmdUpdateType, InfoType, CmdLineUpdateType, RemotePtrType};
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};