diff --git a/CHANGELOG.md b/CHANGELOG.md index ed1f9d6cc..b9745ad2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie --- +## [1.1.89] – 2025-05-22 + +### Changed + +- Recoil-Atoms `mapIdState` und `userIdState` entfernt +- Stattdessen: Umstellung auf Redux-Slice `urlParameterSlice` +- `MapComponent.js` verwendet jetzt: + - `useSelector(...)` für `mapId` und `userId` + - `dispatch(setMapId(...))`, `dispatch(setUserId(...))` in `useEffect` +- Redux-Store erweitert um `urlParameterReducer` + +### Removed + +- Recoil-Import `useRecoilState(mapIdState / userIdState)` entfernt aus `MapComponent.js` + +--- + ## [1.1.88] – 2025-05-22 ### Changed diff --git a/components/mainComponent/MapComponent.js b/components/mainComponent/MapComponent.js index 4b9b9c873..357903b67 100644 --- a/components/mainComponent/MapComponent.js +++ b/components/mainComponent/MapComponent.js @@ -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 diff --git a/config/appVersion.js b/config/appVersion.js index d4b388c16..9aba4f932 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.88"; +export const APP_VERSION = "1.1.89"; diff --git a/redux/slices/urlParameterSlice.js b/redux/slices/urlParameterSlice.js index 053529ebc..212f00297 100644 --- a/redux/slices/urlParameterSlice.js +++ b/redux/slices/urlParameterSlice.js @@ -1,14 +1,28 @@ -// /redux/slices/urlParameterSlice.js -import { atom } from "recoil"; +// redux/slices/urlParameterSlice.js +import { createSlice } from "@reduxjs/toolkit"; -// Atom für die Speicherung der mapId aus der URL -export const mapIdState = atom({ - key: "mapIdState", // Eindeutiger Schlüssel (innerhalb des gesamten Projekts) - default: "10", // Standardwert +const initialState = { + mapId: "10", + userId: "484", +}; + +const urlParameterSlice = createSlice({ + name: "urlParameter", + initialState, + reducers: { + setMapId: (state, action) => { + state.mapId = action.payload; + }, + setUserId: (state, action) => { + state.userId = action.payload; + }, + setFromURL: (state, action) => { + const { m, u } = action.payload; + if (m) state.mapId = m; + if (u) state.userId = u; + }, + }, }); -// Atom für die Speicherung der userId aus der URL -export const userIdState = atom({ - key: "userIdState", - default: "484", -}); +export const { setMapId, setUserId, setFromURL } = urlParameterSlice.actions; +export default urlParameterSlice.reducer; diff --git a/redux/store.js b/redux/store.js index 4a5fbbcf6..fdf72afde 100644 --- a/redux/store.js +++ b/redux/store.js @@ -21,6 +21,7 @@ import polylineEventsDisabledReducer from "./slices/polylineEventsDisabledSlice" import readPoiMarkersStoreReducer from "./slices/readPoiMarkersStoreSlice"; import selectedAreaReducer from "./slices/selectedAreaSlice"; import zoomTriggerReducer from "./slices/zoomTriggerSlice"; +import urlParameterReducer from "./slices/urlParameterSlice"; export const store = configureStore({ reducer: { @@ -45,5 +46,6 @@ export const store = configureStore({ readPoiMarkersStore: readPoiMarkersStoreReducer, selectedArea: selectedAreaReducer, zoomTrigger: zoomTriggerReducer, + urlParameter: urlParameterReducer, }, });