send initial local server status

This commit is contained in:
sawka 2022-10-30 13:06:25 -07:00
parent 4078cb1f1e
commit ebb196f164
4 changed files with 10 additions and 2 deletions

View File

@ -245,6 +245,11 @@ electron.ipcMain.on("get-id", (event) => {
return;
});
electron.ipcMain.on("local-server-status", (event) => {
event.returnValue = (localServerProc != null);
return;
});
electron.ipcMain.on("restart-server", (event) => {
if (localServerProc != null) {
localServerProc.kill();

View File

@ -2587,7 +2587,7 @@ class Main extends React.Component<{}, {}> {
<MainSideBar/>
<SessionView/>
</div>
<If condition={!GlobalModel.ws.open.get()}>
<If condition={!GlobalModel.ws.open.get() || !GlobalModel.localServerRunning.get()}>
<DisconnectedModal/>
</If>
</div>

View File

@ -1529,13 +1529,15 @@ class Model {
termUsedRowsCache : Record<string, number> = {};
debugCmds : number = 0;
debugSW : OV<boolean> = mobx.observable.box(false);
localServerRunning : OV<boolean> = mobx.observable.box(false);
localServerRunning : OV<boolean>;
constructor() {
this.clientId = getApi().getId();
this.ws = new WSControl(this.clientId, (message : any) => this.runUpdate(message, false));
this.ws.reconnect();
this.inputModel = new InputModel();
let isLocalServerRunning = getApi().getLocalServerStatus();
this.localServerRunning = mobx.observable.box(isLocalServerRunning);
getApi().onTCmd(this.onTCmd.bind(this));
getApi().onICmd(this.onICmd.bind(this));
getApi().onLCmd(this.onLCmd.bind(this));

View File

@ -2,6 +2,7 @@ let {contextBridge, ipcRenderer} = require("electron");
contextBridge.exposeInMainWorld("api", {
getId: () => ipcRenderer.sendSync("get-id"),
getLocalServerStatus: () => ipcRenderer.sendSync("local-server-status"),
restartLocalServer: () => ipcRenderer.sendSync("restart-server"),
onTCmd: (callback) => ipcRenderer.on("t-cmd", callback),
onICmd: (callback) => ipcRenderer.on("i-cmd", callback),