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 MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const isPolylineContextMenuOpen = useSelector((state) => state.polylineContextMenu.isOpen);
|
|
||||||
const countdown = useSelector((state) => state.polylineContextMenu.countdown);
|
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 contextMenuState = useSelector((state) => state.polylineContextMenu);
|
||||||
|
|
||||||
const polylinePosition = contextMenuState.position ? L.latLng(contextMenuState.position.lat, contextMenuState.position.lng) : null;
|
const polylinePosition = contextMenuState.position ? L.latLng(contextMenuState.position.lat, contextMenuState.position.lng) : null;
|
||||||
@@ -1065,13 +1067,13 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
|
|
||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isPolylineContextMenuOpen) {
|
if (isPolylineContextMenuOpen && countdownActive) {
|
||||||
console.log("🔄 Starte Redux-Countdown für Kontextmenü!");
|
//console.log("🔄 Starte Redux-Countdown für Kontextmenü!");
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
dispatch(updateCountdown());
|
dispatch(updateCountdown());
|
||||||
|
|
||||||
console.log(`⏳ Redux Countdown: ${countdown} Sekunden`);
|
// console.log(`⏳ Redux Countdown: ${countdown} Sekunden`);
|
||||||
|
|
||||||
if (countdown <= 2) {
|
if (countdown <= 2) {
|
||||||
console.log("🚀 Kontextmenü wird wegen Countdown < 2 geschlossen.");
|
console.log("🚀 Kontextmenü wird wegen Countdown < 2 geschlossen.");
|
||||||
@@ -1089,8 +1091,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [isPolylineContextMenuOpen, countdown, dispatch, window.map]);
|
}, [isPolylineContextMenuOpen, countdown, countdownActive, dispatch, window.map]);
|
||||||
|
|
||||||
//----------------------------------
|
//----------------------------------
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (map) {
|
if (map) {
|
||||||
@@ -1100,6 +1101,22 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
}, [map]);
|
}, [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 (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// /config/appVersion
|
// /config/appVersion
|
||||||
export const APP_VERSION = "1.1.43";
|
export const APP_VERSION = "1.1.44";
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const initialState = {
|
|||||||
forceClose: false,
|
forceClose: false,
|
||||||
timerStart: null,
|
timerStart: null,
|
||||||
countdown: 20,
|
countdown: 20,
|
||||||
|
countdownActive: false, // **Neu: Redux merkt, ob der Timer aktiv ist**
|
||||||
};
|
};
|
||||||
|
|
||||||
const polylineContextMenuSlice = createSlice({
|
const polylineContextMenuSlice = createSlice({
|
||||||
@@ -19,17 +20,25 @@ const polylineContextMenuSlice = createSlice({
|
|||||||
state.forceClose = false;
|
state.forceClose = false;
|
||||||
state.timerStart = Date.now();
|
state.timerStart = Date.now();
|
||||||
state.countdown = 20;
|
state.countdown = 20;
|
||||||
|
state.countdownActive = true; // **Timer aktiv setzen**
|
||||||
},
|
},
|
||||||
closePolylineContextMenu: (state) => {
|
closePolylineContextMenu: (state) => {
|
||||||
state.isOpen = false;
|
state.isOpen = false;
|
||||||
state.position = null;
|
state.position = null;
|
||||||
state.timerStart = null;
|
state.timerStart = null;
|
||||||
state.countdown = 0;
|
state.countdown = 0;
|
||||||
|
state.countdownActive = false; // **Timer stoppen**
|
||||||
},
|
},
|
||||||
updateCountdown: (state) => {
|
updateCountdown: (state) => {
|
||||||
if (state.timerStart) {
|
if (state.timerStart && state.countdownActive) {
|
||||||
const elapsedTime = (Date.now() - state.timerStart) / 1000;
|
const elapsedTime = (Date.now() - state.timerStart) / 1000;
|
||||||
state.countdown = Math.max(20 - elapsedTime, 0);
|
state.countdown = Math.max(20 - elapsedTime, 0);
|
||||||
|
|
||||||
|
if (state.countdown <= 2) {
|
||||||
|
state.isOpen = false;
|
||||||
|
state.position = null;
|
||||||
|
state.countdownActive = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
forceCloseContextMenu: (state) => {
|
forceCloseContextMenu: (state) => {
|
||||||
@@ -38,6 +47,7 @@ const polylineContextMenuSlice = createSlice({
|
|||||||
state.forceClose = true;
|
state.forceClose = true;
|
||||||
state.timerStart = null;
|
state.timerStart = null;
|
||||||
state.countdown = 0;
|
state.countdown = 0;
|
||||||
|
state.countdownActive = false;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -303,21 +303,27 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents,
|
|||||||
|
|
||||||
polyline.setStyle({ weight: 14 });
|
polyline.setStyle({ weight: 14 });
|
||||||
const link = `${process.env.NEXT_PUBLIC_BASE_URL}cpl.aspx?ver=35&kue=24&id=${lineData.idLD}`;
|
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.on("mouseout", (e) => {
|
||||||
polyline.setStyle({ weight: 3 });
|
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) {
|
document.addEventListener("click", function handleOutsideClick(event) {
|
||||||
if (!event.target.closest(".leaflet-contextmenu")) {
|
if (!event.target.closest(".leaflet-contextmenu")) {
|
||||||
console.log("🛑 Klick außerhalb des Kontextmenüs erkannt - Schließe Menü.");
|
console.log("🛑 Klick außerhalb des Kontextmenüs erkannt - Schließe Menü.");
|
||||||
store.dispatch(closePolylineContextMenu());
|
|
||||||
store.dispatch(forceCloseContextMenu());
|
|
||||||
|
|
||||||
if (window.map?.contextmenu) {
|
try {
|
||||||
window.map.contextmenu.hide();
|
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);
|
document.removeEventListener("click", handleOutsideClick);
|
||||||
|
|||||||
Reference in New Issue
Block a user