From 77bf19a1c8efe7a609828ba97f8841745d779b78 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 28 Feb 2024 17:42:10 +0100 Subject: [PATCH] Remove Reload --- src/pages/dashboard.astro | 10 ++++++---- src/pages/login.astro | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/pages/dashboard.astro b/src/pages/dashboard.astro index 9c30cf4..1315fcb 100644 --- a/src/pages/dashboard.astro +++ b/src/pages/dashboard.astro @@ -9,11 +9,13 @@ import {t} from "astro-i18n"; import {l} from "../util/util"; import {navigate} from "astro:transitions/client"; - if (window.location.href.endsWith("/dashboard") || window.location.href.endsWith("/dashboard/")) { - if ((localStorage.getItem("sw-session") ?? "") === "") { - navigate(l("/login"), {}); + document.addEventListener("astro:page-load", () => { + if (window.location.href.endsWith("/dashboard") || window.location.href.endsWith("/dashboard/")) { + if ((localStorage.getItem("sw-session") ?? "") === "") { + navigate(l("/login"), {}); + } } - } + }); \ No newline at end of file diff --git a/src/pages/login.astro b/src/pages/login.astro index a634026..d654e5d 100644 --- a/src/pages/login.astro +++ b/src/pages/login.astro @@ -11,11 +11,13 @@ import localBau from "@images/2023-10-08_20.43.43.png"; import {l} from "../util/util"; import {navigate} from "astro:transitions/client"; - if (window.location.href.endsWith("/login") || window.location.href.endsWith("/login/")) { - if ((localStorage.getItem("sw-session") ?? "") !== "") { - navigate(l("/dashboard")); + document.addEventListener("astro:page-load", () => { + if (window.location.href.endsWith("/login") || window.location.href.endsWith("/login/")) { + if ((localStorage.getItem("sw-session") ?? "") !== "") { + navigate(l("/dashboard"), {history: "replace"}); + } } - } + }); Bau