From e6f60ff2101aac5701a44d7e601522aca39c5de9 Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Tue, 23 Jul 2024 12:46:29 -0700 Subject: [PATCH] more const crusade --- frontend/app/store/global.ts | 8 ++++---- frontend/app/store/wos.ts | 4 ++-- frontend/app/store/ws.ts | 8 ++++---- frontend/app/store/wshrpc.ts | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/app/store/global.ts b/frontend/app/store/global.ts index 97fc267dd..eabd97e61 100644 --- a/frontend/app/store/global.ts +++ b/frontend/app/store/global.ts @@ -295,7 +295,7 @@ function handleWSMessage(msg: any) { } function initWS() { - let windowId = globalStore.get(atoms.windowId); + const windowId = globalStore.get(atoms.windowId); globalWS = new WSControl(getWSServerEndpoint(), globalStore, windowId, "", (msg) => { handleWSMessage(msg); }); @@ -344,7 +344,7 @@ async function fetchWaveFile( fileName: string, offset?: number ): Promise<{ data: Uint8Array; fileInfo: WaveFile }> { - let usp = new URLSearchParams(); + const usp = new URLSearchParams(); usp.set("zoneid", zoneId); usp.set("name", fileName); if (offset != null) { @@ -360,11 +360,11 @@ async function fetchWaveFile( if (resp.status == 204) { return { data: null, fileInfo: null }; } - let fileInfo64 = resp.headers.get("X-ZoneFileInfo"); + const fileInfo64 = resp.headers.get("X-ZoneFileInfo"); if (fileInfo64 == null) { throw new Error(`missing zone file info for ${zoneId}:${fileName}`); } - let fileInfo = JSON.parse(atob(fileInfo64)); + const fileInfo = JSON.parse(atob(fileInfo64)); const data = await resp.arrayBuffer(); return { data: new Uint8Array(data), fileInfo }; } diff --git a/frontend/app/store/wos.ts b/frontend/app/store/wos.ts index 04a4ad9d0..e30a43e4d 100644 --- a/frontend/app/store/wos.ts +++ b/frontend/app/store/wos.ts @@ -115,7 +115,7 @@ function wshServerRpcHelper_responsestream( if (opts?.noresponse) { throw new Error("noresponse not supported for responsestream calls"); } - let msg: RpcMessage = { + const msg: RpcMessage = { command: command, data: data, reqid: uuidv4(), @@ -128,7 +128,7 @@ function wshServerRpcHelper_responsestream( } function wshServerRpcHelper_call(command: string, data: any, opts: WshRpcCommandOpts): Promise { - let msg: RpcMessage = { + const msg: RpcMessage = { command: command, data: data, }; diff --git a/frontend/app/store/ws.ts b/frontend/app/store/ws.ts index a06ac88b3..fda5fe0ec 100644 --- a/frontend/app/store/ws.ts +++ b/frontend/app/store/ws.ts @@ -44,7 +44,7 @@ class WSControl { } log(str: string) { - let ts = Date.now(); + const ts = Date.now(); this.wsLog.push("[" + ts + "] " + str); if (this.wsLog.length > 50) { this.wsLog.splice(0, this.wsLog.length - 50); @@ -86,7 +86,7 @@ class WSControl { this.log("cannot connect, giving up"); return; } - let timeoutArr = [0, 0, 2, 5, 10, 10, 30, 60]; + const timeoutArr = [0, 0, 2, 5, 10, 10, 30, 60]; let timeout = 60; if (this.reconnectTimes < timeoutArr.length) { timeout = timeoutArr[this.reconnectTimes]; @@ -131,7 +131,7 @@ class WSControl { if (this.msgQueue.length == 0) { return; } - let msg = this.msgQueue.shift(); + const msg = this.msgQueue.shift(); this.sendMessage(msg); setTimeout(() => { this.runMsgQueue(); @@ -178,7 +178,7 @@ class WSControl { if (!this.isOpen()) { return; } - let msg = JSON.stringify(data); + const msg = JSON.stringify(data); const byteSize = new Blob([msg]).size; if (byteSize > MaxWebSocketSendSize) { console.log("ws message too large", byteSize, data.wscommand, msg.substring(0, 100)); diff --git a/frontend/app/store/wshrpc.ts b/frontend/app/store/wshrpc.ts index 5d4d42fbd..ea1729334 100644 --- a/frontend/app/store/wshrpc.ts +++ b/frontend/app/store/wshrpc.ts @@ -66,7 +66,7 @@ async function* rpcResponseGenerator( } function sendRpcCommand(msg: RpcMessage): AsyncGenerator { - let wsMsg: WSRpcCommand = { wscommand: "rpc", message: msg }; + const wsMsg: WSRpcCommand = { wscommand: "rpc", message: msg }; globalWS.pushMessage(wsMsg); if (msg.reqid == null) { return null;