fix: Leistung etwas verbessert wegen Kabelstrecken anzeigen und ausblenden
This commit is contained in:
@@ -153,7 +153,10 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const [oms, setOms] = useState(null); // State für OMS-Instanz
|
||||
|
||||
// Flag, ob Nutzer die Polyline-Checkbox manuell betätigt hat
|
||||
const userToggledPolyline = useRef(false);
|
||||
// Nutzer-Flag global auf window, damit auch Redux darauf zugreifen kann
|
||||
if (typeof window !== "undefined" && window.userToggledPolyline === undefined) {
|
||||
window.userToggledPolyline = false;
|
||||
}
|
||||
|
||||
//-----userRights----------------
|
||||
const isRightsLoaded = useSelector(
|
||||
@@ -305,7 +308,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
// Callback für Checkbox-Umschaltung (Kabelstrecken)
|
||||
const handlePolylineCheckboxChange = useCallback(
|
||||
checked => {
|
||||
userToggledPolyline.current = true;
|
||||
if (typeof window !== "undefined") {
|
||||
window.userToggledPolyline = true;
|
||||
}
|
||||
dispatch(setPolylineVisible(checked));
|
||||
},
|
||||
[dispatch]
|
||||
@@ -1031,7 +1036,10 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
</div>
|
||||
|
||||
{GisStationsStaticDistrict && GisStationsStaticDistrict.Points?.length > 0 && (
|
||||
<MapLayersControlPanel className="z-50" />
|
||||
<MapLayersControlPanel
|
||||
className="z-50"
|
||||
handlePolylineCheckboxChange={handlePolylineCheckboxChange}
|
||||
/>
|
||||
)}
|
||||
|
||||
<CoordinateInput onCoordinatesSubmit={handleCoordinatesSubmit} />
|
||||
|
||||
@@ -14,7 +14,7 @@ import { selectMapLayersState, setLayerVisibility } from "@/redux/slices/mapLaye
|
||||
import { setVisible } from "@/redux/slices/database/pois/poiLayerVisibleSlice";
|
||||
import { incrementZoomTrigger } from "@/redux/slices/zoomTriggerSlice";
|
||||
|
||||
function MapLayersControlPanel() {
|
||||
function MapLayersControlPanel({ handlePolylineCheckboxChange }) {
|
||||
const [editMode, setEditMode] = useState(false); // Zustand für editMode
|
||||
const [localStorageLoaded, setLocalStorageLoaded] = useState(false); // Tracking ob localStorage geladen wurde
|
||||
const kabelstreckenVisible = useSelector(selectPolylineVisible); // Nur noch Redux
|
||||
@@ -39,36 +39,7 @@ function MapLayersControlPanel() {
|
||||
)
|
||||
: false;
|
||||
|
||||
const handlePolylineCheckboxChange = event => {
|
||||
const checked = event.target.checked;
|
||||
// Debug-Ausgabe
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const mapId = params.get("m");
|
||||
const userId = params.get("u");
|
||||
const polylineKey =
|
||||
mapId && userId ? `polylineVisible_m${mapId}_u${userId}` : "polylineVisible";
|
||||
console.log(
|
||||
"[UI/handlePolylineCheckboxChange] checked:",
|
||||
checked,
|
||||
"Redux:",
|
||||
kabelstreckenVisible,
|
||||
"localStorage:",
|
||||
localStorage.getItem(polylineKey)
|
||||
);
|
||||
dispatch(setPolylineVisible(checked));
|
||||
// Wenn aktiviert, TALAS aktivieren
|
||||
if (checked) {
|
||||
const talasKey = "system-1";
|
||||
dispatch(setLayerVisibility({ layer: talasKey, visibility: true }));
|
||||
// Optional: mapLayersVisibility im localStorage aktualisieren, aber nicht mehr für Sichtbarkeit nutzen
|
||||
const mapId = localStorage.getItem("currentMapId");
|
||||
const userId = localStorage.getItem("currentUserId");
|
||||
const mapStorageKey =
|
||||
mapId && userId ? `mapLayersVisibility_m${mapId}_u${userId}` : "mapLayersVisibility";
|
||||
const updatedVisibility = { ...mapLayersVisibility, [talasKey]: true };
|
||||
localStorage.setItem(mapStorageKey, JSON.stringify(updatedVisibility));
|
||||
}
|
||||
};
|
||||
// handlePolylineCheckboxChange kommt jetzt als Prop von MapComponent
|
||||
|
||||
useEffect(() => {
|
||||
// LocalStorage Werte beim ersten Laden der Komponente wiederherstellen (nur für POI und mapLayersVisibility, nicht mehr für Kabelstrecken)
|
||||
@@ -338,8 +309,8 @@ function MapLayersControlPanel() {
|
||||
<div className="flex items-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={kabelstreckenVisible} // Lokaler State statt Redux
|
||||
onChange={handlePolylineCheckboxChange}
|
||||
checked={kabelstreckenVisible}
|
||||
onChange={e => handlePolylineCheckboxChange(e.target.checked)}
|
||||
id="polyline-checkbox"
|
||||
disabled={!isTalasAllowed || editMode}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user