refactor: Entfernt Recoil-Atoms mapIdState & userIdState – ersetzt durch Redux-Slice urlParameter
- MapComponent.js nutzt jetzt useSelector für mapId/userId - Übergabe dynamischer Parameter via dispatch(setMapId), dispatch(setUserId) - Store um urlParameterReducer erweitert
This commit is contained in:
@@ -38,7 +38,6 @@ import { updateLocation } from "../../utils/updateBereichUtil.js";
|
||||
//--------------------------------------------
|
||||
//import { currentPoiState } from "../redux/slices/currentPoiSlice.js";
|
||||
|
||||
import { mapIdState, userIdState } from "../../redux/slices/urlParameterSlice.js";
|
||||
import { selectedPoiState } from "../../redux/slices/selectedPoiSlice.js";
|
||||
import { gisSystemStaticState } from "../../redux/slices/webService/gisSystemStaticSlice.js";
|
||||
import { selectMapLayersState } from "../../redux/slices/mapLayersSlice";
|
||||
@@ -83,6 +82,7 @@ import useRestoreMapSettings from "./hooks/useRestoreMapSettings";
|
||||
import { setSelectedPoi, clearSelectedPoi } from "../../redux/slices/selectedPoiSlice";
|
||||
import { setupDevices } from "../../utils/setupDevices";
|
||||
import { setDisabled } from "../../redux/slices/polylineEventsDisabledSlice";
|
||||
import { setMapId, setUserId } from "../../redux/slices/urlParameterSlice";
|
||||
|
||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const dispatch = useDispatch();
|
||||
@@ -129,8 +129,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const poiLayerVisible = useSelector((state) => state.poiLayerVisible.visible);
|
||||
const [isRightsLoaded, setIsRightsLoaded] = useState(false);
|
||||
const [hasRights, setHasRights] = useState(false);
|
||||
const [mapId, setMapId] = useRecoilState(mapIdState);
|
||||
const [userId, setUserId] = useRecoilState(userIdState);
|
||||
|
||||
const [AddPoiModalWindowState, setAddPoiModalWindowState] = useState(false);
|
||||
const [userRights, setUserRights] = useState(null);
|
||||
|
||||
@@ -252,12 +251,14 @@ 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)));
|
||||
const mapId = useSelector((state) => state.urlParameter.mapId);
|
||||
const userId = useSelector((state) => state.urlParameter.userId);
|
||||
//---------------------------------------------------------------
|
||||
useEffect(() => {
|
||||
const params = new URL(window.location.href).searchParams;
|
||||
setMapId(params.get("m"));
|
||||
setUserId(params.get("u"));
|
||||
}, [setMapId, setUserId]);
|
||||
dispatch(setMapId(params.get("m")));
|
||||
dispatch(setUserId(params.get("u")));
|
||||
}, [dispatch]);
|
||||
//---------------------------------------------------------------
|
||||
useFetchWebServiceMap(mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl, setGisStationsStatusDistrict, setGisStationsMeasurements, setGisSystemStatic, setGisSystemStaticLoaded);
|
||||
//Test in useEffect
|
||||
|
||||
Reference in New Issue
Block a user