fix: Leistung etwas verbessert wegen Kabelstrecken anzeigen und ausblenden
This commit is contained in:
@@ -23,4 +23,4 @@ NEXT_PUBLIC_USE_MOCKS=true
|
||||
# z.B. http://10.10.0.13/xyz/index.aspx -> basePath in config.json auf /xyz setzen
|
||||
# basePath wird jetzt in public/config.json gepflegt
|
||||
# App-Versionsnummer
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.345
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.346
|
||||
|
||||
@@ -24,4 +24,4 @@ NEXT_PUBLIC_USE_MOCKS=false
|
||||
# basePath wird jetzt in public/config.json gepflegt
|
||||
|
||||
# App-Versionsnummer
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.345
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.346
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "nodemap",
|
||||
"version": "1.1.345",
|
||||
"version": "1.1.346",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "nodemap",
|
||||
"version": "1.1.345",
|
||||
"version": "1.1.346",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/styled": "^11.13.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nodemap",
|
||||
"version": "1.1.345",
|
||||
"version": "1.1.346",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/styled": "^11.13.0",
|
||||
|
||||
@@ -5,6 +5,13 @@ import { createSlice } from "@reduxjs/toolkit";
|
||||
// Thunk to initialize polyline visibility from localStorage using mapId/userId from URL
|
||||
export const initializePolylineFromLocalStorageThunk = () => dispatch => {
|
||||
try {
|
||||
// Prüfe globales Nutzer-Flag
|
||||
if (typeof window !== "undefined" && window.userToggledPolyline) {
|
||||
console.log(
|
||||
"[Redux] Initialisierung abgebrochen: Nutzer hat Polyline bereits manuell geändert."
|
||||
);
|
||||
return;
|
||||
}
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const mapId = params.get("m");
|
||||
const userId = params.get("u");
|
||||
@@ -60,6 +67,12 @@ const polylineLayerVisibleSlice = createSlice({
|
||||
},
|
||||
initializePolylineFromLocalStorage: (state, action) => {
|
||||
// Diese Action wird nur beim Initialisieren aus localStorage verwendet
|
||||
if (typeof window !== "undefined" && window.userToggledPolyline) {
|
||||
console.log(
|
||||
"[Redux] Initialisierung im Reducer abgebrochen: Nutzer hat Polyline bereits manuell geändert."
|
||||
);
|
||||
return;
|
||||
}
|
||||
state.visible = action.payload;
|
||||
state.isInitialized = true;
|
||||
console.log(
|
||||
|
||||
Reference in New Issue
Block a user