Seite neu laden wenn die Fehler kommt , aber wird kurz angezeigt
This commit is contained in:
@@ -84,8 +84,10 @@ import { updateCountdown, closePolylineContextMenu, forceCloseContextMenu } from
|
||||
|
||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const dispatch = useDispatch();
|
||||
const isPolylineContextMenuOpen = useSelector((state) => state.polylineContextMenu.isOpen);
|
||||
const countdown = useSelector((state) => state.polylineContextMenu.countdown);
|
||||
const countdownActive = useSelector((state) => state.polylineContextMenu.countdownActive);
|
||||
const isPolylineContextMenuOpen = useSelector((state) => state.polylineContextMenu.isOpen);
|
||||
|
||||
const contextMenuState = useSelector((state) => state.polylineContextMenu);
|
||||
|
||||
const polylinePosition = contextMenuState.position ? L.latLng(contextMenuState.position.lat, contextMenuState.position.lng) : null;
|
||||
@@ -1065,13 +1067,13 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
|
||||
//--------------------------------------
|
||||
useEffect(() => {
|
||||
if (isPolylineContextMenuOpen) {
|
||||
console.log("🔄 Starte Redux-Countdown für Kontextmenü!");
|
||||
if (isPolylineContextMenuOpen && countdownActive) {
|
||||
//console.log("🔄 Starte Redux-Countdown für Kontextmenü!");
|
||||
|
||||
const interval = setInterval(() => {
|
||||
dispatch(updateCountdown());
|
||||
|
||||
console.log(`⏳ Redux Countdown: ${countdown} Sekunden`);
|
||||
// console.log(`⏳ Redux Countdown: ${countdown} Sekunden`);
|
||||
|
||||
if (countdown <= 2) {
|
||||
console.log("🚀 Kontextmenü wird wegen Countdown < 2 geschlossen.");
|
||||
@@ -1089,8 +1091,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}
|
||||
}, [isPolylineContextMenuOpen, countdown, dispatch, window.map]);
|
||||
|
||||
}, [isPolylineContextMenuOpen, countdown, countdownActive, dispatch, window.map]);
|
||||
//----------------------------------
|
||||
useEffect(() => {
|
||||
if (map) {
|
||||
@@ -1100,6 +1101,22 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}, [map]);
|
||||
|
||||
//---------------------------------------
|
||||
useEffect(() => {
|
||||
window.onerror = function (message, source, lineno, colno, error) {
|
||||
if (message.includes("Cannot read properties of null (reading 'contextmenu')")) {
|
||||
console.warn("⚠️ Fehler mit `contextmenu` erkannt - Neuladen der Seite.");
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 2000); // **Seite nach 2 Sekunden neu laden**
|
||||
}
|
||||
};
|
||||
|
||||
return () => {
|
||||
window.onerror = null; // **Fehlerbehandlung entfernen, wenn Komponente unmounted wird**
|
||||
};
|
||||
}, []);
|
||||
|
||||
//---------------------------------------------
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// /config/appVersion
|
||||
export const APP_VERSION = "1.1.43";
|
||||
export const APP_VERSION = "1.1.44";
|
||||
|
||||
@@ -7,6 +7,7 @@ const initialState = {
|
||||
forceClose: false,
|
||||
timerStart: null,
|
||||
countdown: 20,
|
||||
countdownActive: false, // **Neu: Redux merkt, ob der Timer aktiv ist**
|
||||
};
|
||||
|
||||
const polylineContextMenuSlice = createSlice({
|
||||
@@ -19,17 +20,25 @@ const polylineContextMenuSlice = createSlice({
|
||||
state.forceClose = false;
|
||||
state.timerStart = Date.now();
|
||||
state.countdown = 20;
|
||||
state.countdownActive = true; // **Timer aktiv setzen**
|
||||
},
|
||||
closePolylineContextMenu: (state) => {
|
||||
state.isOpen = false;
|
||||
state.position = null;
|
||||
state.timerStart = null;
|
||||
state.countdown = 0;
|
||||
state.countdownActive = false; // **Timer stoppen**
|
||||
},
|
||||
updateCountdown: (state) => {
|
||||
if (state.timerStart) {
|
||||
if (state.timerStart && state.countdownActive) {
|
||||
const elapsedTime = (Date.now() - state.timerStart) / 1000;
|
||||
state.countdown = Math.max(20 - elapsedTime, 0);
|
||||
|
||||
if (state.countdown <= 2) {
|
||||
state.isOpen = false;
|
||||
state.position = null;
|
||||
state.countdownActive = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
forceCloseContextMenu: (state) => {
|
||||
@@ -38,6 +47,7 @@ const polylineContextMenuSlice = createSlice({
|
||||
state.forceClose = true;
|
||||
state.timerStart = null;
|
||||
state.countdown = 0;
|
||||
state.countdownActive = false;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -303,21 +303,27 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents,
|
||||
|
||||
polyline.setStyle({ weight: 14 });
|
||||
const link = `${process.env.NEXT_PUBLIC_BASE_URL}cpl.aspx?ver=35&kue=24&id=${lineData.idLD}`;
|
||||
console.log("Link der Linie:", link);
|
||||
// console.log("Link der Linie:", link);
|
||||
});
|
||||
|
||||
polyline.on("mouseout", (e) => {
|
||||
polyline.setStyle({ weight: 3 });
|
||||
console.log("🚀 Maus hat die Polyline verlassen - Warten auf Klick außerhalb des Menüs.");
|
||||
// console.log("🚀 Maus hat die Polyline verlassen - Warten auf Klick außerhalb des Menüs.");
|
||||
|
||||
document.addEventListener("click", function handleOutsideClick(event) {
|
||||
if (!event.target.closest(".leaflet-contextmenu")) {
|
||||
console.log("🛑 Klick außerhalb des Kontextmenüs erkannt - Schließe Menü.");
|
||||
store.dispatch(closePolylineContextMenu());
|
||||
store.dispatch(forceCloseContextMenu());
|
||||
|
||||
if (window.map?.contextmenu) {
|
||||
window.map.contextmenu.hide();
|
||||
try {
|
||||
store.dispatch(closePolylineContextMenu());
|
||||
store.dispatch(forceCloseContextMenu());
|
||||
|
||||
if (window.map?.contextmenu) {
|
||||
window.map.contextmenu.hide();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("❌ Fehler beim Schließen des Kontextmenüs:", error);
|
||||
window.location.reload(); // **Seite neu laden, wenn ein Fehler auftritt**
|
||||
}
|
||||
|
||||
document.removeEventListener("click", handleOutsideClick);
|
||||
|
||||
Reference in New Issue
Block a user