feat: Persist checkbox states in localStorage to retain settings after page reload

- Implemented logic to save the visibility states of POI and map layers in localStorage.
- Loaded saved checkbox states on component mount to retain user preferences.
- Updated `handleCheckboxChange` and `handlePoiCheckboxChange` to store changes in localStorage.
- Ensured that settings persist across page reloads for a better user experience.
This commit is contained in:
ISA
2024-09-11 09:38:51 +02:00
parent f5e9de16f6
commit f16d389dfd
3 changed files with 38 additions and 11 deletions

View File

@@ -7,8 +7,22 @@ wss.on("connection", (ws) => {
console.log("New WebSocket connection");
ws.on("message", (message) => {
console.log("Received:", message);
ws.send(JSON.stringify({ message: "Hallo vom WebSocket-Server" }));
// Konvertiere den Buffer in einen String
const messageString = message.toString();
console.log("Received:", messageString);
// Versuche die Nachricht in JSON zu parsen
try {
const parsedMessage = JSON.parse(messageString);
// Beispielnachricht an den Client zurücksenden
if (parsedMessage.type === "test") {
ws.send(JSON.stringify({ message: `Hallo zurück, ${parsedMessage.message}` }));
}
} catch (error) {
console.error("Fehler beim Parsen der Nachricht:", error);
}
});
ws.on("close", () => {