cleanup: MapComponent.js
This commit is contained in:
@@ -66,6 +66,7 @@ import { fetchGisLinesStatusThunk } from "../../redux/thunks/webservice/fetchGis
|
||||
import { fetchUserRightsThunk } from "../../redux/thunks/webservice/fetchUserRightsThunk";
|
||||
import { selectGisLines } from "../../redux/slices/database/gisLinesSlice";
|
||||
import { selectGisLinesStatus } from "../../redux/slices/webservice/gisLinesStatusSlice";
|
||||
import { selectGisLinesStatusFromWebservice } from "../../redux/slices/webservice/gisLinesStatusSlice";
|
||||
|
||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
//-------------------------------
|
||||
@@ -90,10 +91,10 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const polylineEventsDisabled = useSelector((state) => state.polylineEventsDisabled.disabled);
|
||||
const mapLayersVisibility = useSelector(selectMapLayersState) || {};
|
||||
const selectedArea = useSelector((state) => state.selectedArea.area);
|
||||
const linesData = useSelector((state) => state.gisLines.data);
|
||||
const gisLinesStatus = useSelector((state) => state.gisLines.status);
|
||||
const linesData = useSelector((state) => state.gisLinesFromDatabase.data);
|
||||
const gisLinesStatus = useSelector((state) => state.gisLinesStatusFromWebservice.status);
|
||||
|
||||
const { data: gisLinesStatusData, status: statusGisLinesStatus } = useSelector(selectGisLinesStatus);
|
||||
const { data: gisLinesStatusData, status: statusGisLinesStatus } = useSelector(selectGisLinesStatusFromWebservice);
|
||||
useEffect(() => {
|
||||
console.log("✅ Redux: gisLinesStatusData:", gisLinesStatusData);
|
||||
}, [gisLinesStatusData]);
|
||||
@@ -219,31 +220,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const sonstigeMarkersLayerRef = useRef(null);
|
||||
const tkComponentsMarkersRef = useRef(null);
|
||||
useInitializeMap(map, mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights, (value) => dispatch(setDisabled(value)));
|
||||
//---------------------------------------------------------------
|
||||
useEffect(() => {
|
||||
const params = new URL(window.location.href).searchParams;
|
||||
dispatch(setMapId(params.get("m")));
|
||||
dispatch(setUserId(params.get("u")));
|
||||
}, [dispatch]);
|
||||
//---------------------------------------------------------------
|
||||
useEffect(() => {
|
||||
dispatch(fetchPriorityConfigThunk());
|
||||
}, [dispatch]);
|
||||
//--------------------------------------------------------
|
||||
useEffect(() => {
|
||||
if (gisLinesStatus === "idle") {
|
||||
dispatch(fetchGisLinesThunk());
|
||||
}
|
||||
}, [gisLinesStatus, dispatch]);
|
||||
//--------------------------------------------------------
|
||||
useEffect(() => {
|
||||
dispatch(fetchGisLinesStatusThunk());
|
||||
}, [dispatch]);
|
||||
//---------------------------------------------------------
|
||||
useEffect(() => {
|
||||
dispatch(fetchUserRightsThunk());
|
||||
}, [dispatch]);
|
||||
//----------------------------------------------------
|
||||
|
||||
useEffect(() => {
|
||||
if (linesData && Array.isArray(linesData)) {
|
||||
@@ -370,13 +346,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
mapLayersVisibility, // Neu: Abhängigkeit für Sichtbarkeitsstatus
|
||||
]);
|
||||
|
||||
//--------------------------------------------
|
||||
useEffect(() => {
|
||||
if (poiTypStatus === "idle") {
|
||||
dispatch(fetchPoiTypes());
|
||||
}
|
||||
}, [poiTypStatus, dispatch]);
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//Tooltip an mouse position anzeigen für die Linien
|
||||
useEffect(() => {
|
||||
@@ -807,6 +776,23 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
dispatch(setPolylineVisible(storedPolylineVisible));
|
||||
}, [dispatch]);
|
||||
//--------------------------------------------
|
||||
useEffect(() => {
|
||||
if (statusStaticDistrict === "idle") {
|
||||
dispatch(fetchGisStationsStaticDistrictThunk());
|
||||
}
|
||||
}, [statusStaticDistrict, dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (statusStatusDistrict === "idle") {
|
||||
dispatch(fetchGisStationsStatusDistrictThunk());
|
||||
}
|
||||
}, [statusStatusDistrict, dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (statusMeasurements === "idle") {
|
||||
dispatch(fetchGisStationsMeasurementsThunk());
|
||||
}
|
||||
}, [statusMeasurements, dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (statusSystem === "idle") {
|
||||
@@ -814,32 +800,41 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}
|
||||
}, [statusSystem, dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (statusStatusDistrict === "idle") {
|
||||
dispatch(fetchGisStationsStatusDistrictThunk());
|
||||
}
|
||||
}, [statusStatusDistrict, dispatch]);
|
||||
|
||||
//----------------------------------------------
|
||||
// speichere location devices in redux store
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchLocationDevicesThunk());
|
||||
}, [dispatch]);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
useEffect(() => {
|
||||
if (statusStaticDistrict === "idle") {
|
||||
dispatch(fetchGisStationsStaticDistrictThunk());
|
||||
}
|
||||
}, [statusStaticDistrict, dispatch]);
|
||||
useEffect(() => {
|
||||
if (statusMeasurements === "idle") {
|
||||
dispatch(fetchGisStationsMeasurementsThunk());
|
||||
}
|
||||
}, [statusMeasurements, dispatch]);
|
||||
useEffect(() => {
|
||||
dispatch(fetchGisSystemStaticThunk());
|
||||
const params = new URL(window.location.href).searchParams;
|
||||
dispatch(setMapId(params.get("m")));
|
||||
dispatch(setUserId(params.get("u")));
|
||||
}, [dispatch]);
|
||||
//---------------------------------------------------------------
|
||||
useEffect(() => {
|
||||
dispatch(fetchPriorityConfigThunk());
|
||||
}, [dispatch]);
|
||||
//--------------------------------------------------------
|
||||
useEffect(() => {
|
||||
if (gisLinesStatus === "idle") {
|
||||
dispatch(fetchGisLinesThunk());
|
||||
}
|
||||
}, [gisLinesStatus, dispatch]);
|
||||
//--------------------------------------------------------
|
||||
useEffect(() => {
|
||||
dispatch(fetchGisLinesStatusThunk());
|
||||
}, [dispatch]);
|
||||
//---------------------------------------------------------
|
||||
const rights = useSelector((state) => state.gisUserRightsFromWebservice.rights);
|
||||
useEffect(() => {
|
||||
dispatch(fetchUserRightsThunk());
|
||||
}, [dispatch]);
|
||||
//----------------------------------------------------
|
||||
useEffect(() => {
|
||||
if (poiTypStatus === "idle") {
|
||||
dispatch(fetchPoiTypes());
|
||||
}
|
||||
}, [poiTypStatus, dispatch]);
|
||||
|
||||
//--------------------------------------
|
||||
useEffect(() => {
|
||||
@@ -869,6 +864,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}
|
||||
}, [isPolylineContextMenuOpen, countdown, countdownActive, dispatch, window.map]);
|
||||
//----------------------------------
|
||||
// map in window setzen für mehr Debugging
|
||||
useEffect(() => {
|
||||
if (map) {
|
||||
window.map = map;
|
||||
@@ -877,6 +873,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}, [map]);
|
||||
|
||||
//---------------------------------------
|
||||
// **Fehlerbehandlung für `contextmenu`**
|
||||
// damit den Fehler mit contextmenu nicht angezeigt wird und überspringt wird und die Seite neu geladen wird
|
||||
useEffect(() => {
|
||||
window.onerror = function (message, source, lineno, colno, error) {
|
||||
if (message.includes("Cannot read properties of null (reading 'contextmenu')")) {
|
||||
@@ -894,7 +892,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}, []);
|
||||
|
||||
//---------------------------------------------
|
||||
|
||||
//--------------------------------------------
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user