loadWindowVariables und variablesSlice entfernt und die daten ausgelagert und chaeckSession.ts erstellt
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Provider } from "react-redux";
|
||||
import store, { useAppDispatch } from "../redux/store";
|
||||
import { loadWindowVariables } from "../utils/loadWindowVariables";
|
||||
import { checkSession } from "../utils/checkSession";
|
||||
import Header from "../components/header/Header";
|
||||
import Navigation from "../components/navigation/Navigation";
|
||||
import Footer from "../components/footer/Footer";
|
||||
@@ -23,28 +23,16 @@ function MyApp({ Component, pageProps }: AppProps) {
|
||||
function AppContent({ Component, pageProps }: AppProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const [sessionExpired, setSessionExpired] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const loadAndStoreVariables = async () => {
|
||||
try {
|
||||
const variables = await loadWindowVariables();
|
||||
if (!variables) throw new Error("Sitzungsfehler");
|
||||
|
||||
//console.log("✅ Window-Variablen geladen:", variables);
|
||||
|
||||
const { ...restVariables } = variables;
|
||||
|
||||
setSessionExpired(false);
|
||||
} catch (error) {
|
||||
console.error("❌ Fehler beim Laden der Sitzung:", error);
|
||||
setSessionExpired(true);
|
||||
}
|
||||
const sessionChecker = async () => {
|
||||
const ok = await checkSession();
|
||||
setSessionExpired(!ok);
|
||||
};
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
loadAndStoreVariables();
|
||||
sessionChecker();
|
||||
|
||||
const intervalId = setInterval(loadAndStoreVariables, 10000);
|
||||
const intervalId = setInterval(sessionChecker, 10000);
|
||||
return () => clearInterval(intervalId);
|
||||
}
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user