WIP: erster aufruf beim wechesln der Karten

This commit is contained in:
ISA
2025-08-21 11:06:27 +02:00
parent da21cba186
commit f11f64d4d7
6 changed files with 19 additions and 54 deletions

View File

@@ -689,40 +689,10 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
}, [dispatch]);
//--------------------------------------------
// Beim ersten Client-Render den Wert aus localStorage laden
// Prüfe beide localStorage-Variablen (neue und alte)
useEffect(() => {
let storedPolylineVisible = localStorage.getItem("kabelstreckenVisible") === "true";
// Fallback auf alte Variable, falls neue nicht existiert
if (localStorage.getItem("kabelstreckenVisible") === null) {
const oldValue = localStorage.getItem("polylineVisible") === "true";
storedPolylineVisible = oldValue;
// Migriere zur neuen Variable
localStorage.setItem("kabelstreckenVisible", oldValue.toString());
}
console.log(
"🔄 MapComponent: Loading polylineVisible from localStorage:",
storedPolylineVisible
);
dispatch(setPolylineVisible(storedPolylineVisible));
}, [dispatch]);
// Die Sichtbarkeit der Polylines wird ausschließlich über Redux gesteuert
// (Initialisierung erfolgt in MapLayersControlPanel)
//--------------------------------------------
// Event-Listener für Polyline-Sichtbarkeitsänderungen
useEffect(() => {
const handlePolylineVisibilityChange = () => {
const storedValue = localStorage.getItem("kabelstreckenVisible") === "true";
console.log("🔄 MapComponent: Received polylineVisibilityChanged event, value:", storedValue);
dispatch(setPolylineVisible(storedValue));
};
window.addEventListener("polylineVisibilityChanged", handlePolylineVisibilityChange);
return () => {
window.removeEventListener("polylineVisibilityChanged", handlePolylineVisibilityChange);
};
}, [dispatch]);
// MapComponent reagiert nicht mehr direkt auf localStorage-Events für polylineVisible
//--------------------------------------------
useEffect(() => {
if (statusStaticDistrict === "idle") {