fix: sessionData not being saved after mission reload

This commit is contained in:
Pax1601 2025-03-25 09:37:55 +01:00
parent 6af6545f09
commit b20134f8f1
3 changed files with 11 additions and 8 deletions

View File

@ -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) {

View File

@ -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 {

View File

@ -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();