From b20134f8f1649119ff2debad66bef65755011cae Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Tue, 25 Mar 2025 09:37:55 +0100 Subject: [PATCH] fix: sessionData not being saved after mission reload --- frontend/react/src/map/map.ts | 2 +- frontend/react/src/server/servermanager.ts | 2 +- frontend/server/src/routes/resources.ts | 15 +++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/react/src/map/map.ts b/frontend/react/src/map/map.ts index a5b89d3f..d3c9c4a8 100644 --- a/frontend/react/src/map/map.ts +++ b/frontend/react/src/map/map.ts @@ -1159,7 +1159,7 @@ export class Map extends L.Map { } #onLeftMouseLongClick(e: any) { - if (this.#isDragging || this.#isSelecting) return; + if (this.#isDragging || this.#isSelecting || this.#isZooming) return; console.log(`Left long click at ${e.latlng}`); if (getApp().getState() === OlympusState.UNIT_CONTROL) { diff --git a/frontend/react/src/server/servermanager.ts b/frontend/react/src/server/servermanager.ts index b304eed6..ba116042 100644 --- a/frontend/react/src/server/servermanager.ts +++ b/frontend/react/src/server/servermanager.ts @@ -17,7 +17,6 @@ import { } from "../constants/constants"; import { AirbasesData, - AlarmState, BullseyesData, CommandModeOptions, GeneralSettings, @@ -816,6 +815,7 @@ export class ServerManager { } checkSessionHash(newSessionHash: string) { + console.log(`Checking session hash: ${newSessionHash}`); if (this.#sessionHash != null) { if (newSessionHash !== this.#sessionHash) location.reload(); } else { diff --git a/frontend/server/src/routes/resources.ts b/frontend/server/src/routes/resources.ts index 77f79d88..c29fb178 100644 --- a/frontend/server/src/routes/resources.ts +++ b/frontend/server/src/routes/resources.ts @@ -34,18 +34,16 @@ module.exports = function (configLocation) { let resConfig = { frontend: { ...config.frontend }, audio: { ...(config.audio ?? {}) }, - controllers: { ...(config.controllers ?? {}) }, + controllers: { ...(config.controllers ?? {}) }, profiles: { ...(profiles ?? {}) }, local: local, }; if (local) { - resConfig["authentication"] = config["authentication"] + resConfig["authentication"] = config["authentication"]; } - res.send( - JSON.stringify(resConfig) - ); + res.send(JSON.stringify(resConfig)); res.end(); } else { res.sendStatus(404); @@ -136,11 +134,14 @@ module.exports = function (configLocation) { req.body.sessionData === undefined ) res.sendStatus(400); + + console.log(`Saving sessionData for ${req.params.profileName} with hash ${sessionHash}`); let thisSessionHash = req.body.sessionHash; if (thisSessionHash !== sessionHash) { sessionHash = thisSessionHash; sessionData = {}; } + sessionData[req.params.profileName] = req.body.sessionData; res.end(); }); @@ -148,10 +149,12 @@ module.exports = function (configLocation) { router.put("/sessiondata/load/:profileName", function (req, res, next) { if (req.body.sessionHash === undefined) res.sendStatus(400); let thisSessionHash = req.body.sessionHash; + console.log(`Returning sessionData for ${req.params.profileName} with hash ${sessionHash}`); if (thisSessionHash !== sessionHash) { sessionHash = thisSessionHash; sessionData = {}; - res.sendStatus(404); + res.send(sessionData); + res.end(); } else { res.send(sessionData[req.params.profileName] ?? {}); res.end();