From 0e388e91637a763651803ed76b570153b0eb81b1 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Sun, 30 Jun 2024 21:33:55 -0400 Subject: [PATCH] pageshow event to check if we got her by history, if so. force reload --- resources/js/app-preload.ts | 40 +++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/resources/js/app-preload.ts b/resources/js/app-preload.ts index 5b2c9e5..1eb8d9d 100644 --- a/resources/js/app-preload.ts +++ b/resources/js/app-preload.ts @@ -21,24 +21,42 @@ const preloader = () => }); }; -if(!getStorageValue("agreed-to-terms")) +const tryToAgree = async() => { - agreeDialog() - .then(() => + if(!getStorageValue("agreed-to-terms")) + { + try { + await agreeDialog(); setStorageValue("agreed-to-terms", true); preloader(); - }) - .catch(() => + } + catch(e) { removeStorageKey("code"); removeStorageKey("theme"); removeStorageKey("layout"); removeStorageKey("version"); - window.location.assign("/disagree"); - }); -} -else -{ - preloader(); + + window.addEventListener("pageshow", (event) => + { + let historyTraversal = event.persisted ||( typeof window.performance != "undefined" && window.performance.navigation.type === 2); + if(historyTraversal) + { + // Handle page restore. + window.location.reload(); + } + }); + + const link = document.createElement('a'); + link.setAttribute('href', "/disagree") + link.click(); + } + } + else + { + preloader(); + } } + +tryToAgree();