fix: Duplizierte Kontextmenü-Einträge verhindert und Cleanup hinzugefügt
- Kontextmenü wird jetzt nur einmal hinzugefügt, wenn es noch nicht existiert. - Vor dem Hinzufügen wird geprüft, ob bereits Einträge existieren, um Duplikate zu vermeiden. - Kontextmenü wird entfernt, wenn außerhalb geklickt wird, um Speicherlecks zu verhindern. - Nutzung eines `Set()` für Menü-IDs, um doppelte Einträge sicher zu verhindern.
This commit is contained in:
@@ -10,6 +10,8 @@ import endIcon from "../components/gisPolylines/icons/EndIcon";
|
||||
import { redrawPolyline } from "./polylines/redrawPolyline";
|
||||
import { openInNewTab } from "../utils/openInNewTab";
|
||||
import { disablePolylineEvents, enablePolylineEvents } from "./polylines/setupPolylines"; // Importiere die Funktionen
|
||||
import { setSelectedPoi, clearSelectedPoi } from "../redux/slices/selectedPoiSlice";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
export const setupPOIs = async (
|
||||
map,
|
||||
@@ -27,7 +29,8 @@ export const setupPOIs = async (
|
||||
toast,
|
||||
setShowPoiUpdateModal,
|
||||
setCurrentPoiData,
|
||||
deviceName
|
||||
deviceName,
|
||||
dispatch
|
||||
) => {
|
||||
const editMode = localStorage.getItem("editMode") === "true"; // Prüfen, ob der Bearbeitungsmodus aktiv ist
|
||||
userRights = editMode ? userRights : undefined; // Nur Berechtigungen anwenden, wenn editMode true ist
|
||||
@@ -83,7 +86,9 @@ export const setupPOIs = async (
|
||||
`);
|
||||
|
||||
marker.on("mouseover", function () {
|
||||
//console.log("Device Name:", marker); // Debugging
|
||||
console.log("Device Name in setupPOIs.js :", marker); // Debugging
|
||||
dispatch(setSelectedPoi(location)); // POI in Redux setzen
|
||||
|
||||
handlePoiSelect(
|
||||
{
|
||||
id: location.idPoi,
|
||||
@@ -105,6 +110,7 @@ export const setupPOIs = async (
|
||||
});
|
||||
|
||||
marker.on("mouseout", function () {
|
||||
dispatch(clearSelectedPoi()); // POI aus Redux entfernen
|
||||
this.closePopup();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user