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 (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user