diff --git a/app/js/main.js b/app/js/main.js index 052d3b9..3c12819 100644 --- a/app/js/main.js +++ b/app/js/main.js @@ -8,7 +8,6 @@ * @link https://TheTempusProject.com * @license https://opensource.org/licenses/MIT [MIT LICENSE] */ - let deferredPrompt; const installPrompt = document.getElementById("install-prompt"); const installButton = document.getElementById("install-button"); @@ -19,7 +18,8 @@ if (!localStorage.getItem("pwaInstallDismissed")) { window.addEventListener("beforeinstallprompt", (event) => { event.preventDefault(); deferredPrompt = event; - installPrompt.classList.add("show"); // Show the prompt + installPrompt.classList.remove("d-none"); + installPrompt.classList.add("d-block"); // Show the prompt }); } @@ -29,13 +29,14 @@ if ( installButton ) { if (deferredPrompt) { deferredPrompt.prompt(); const { outcome } = await deferredPrompt.userChoice; - + if (outcome === "dismissed") { setInstallDismissed(); // Store that the user dismissed the prompt } - + deferredPrompt = null; // Reset prompt - installPrompt.classList.remove("show"); // Hide the prompt + installPrompt.classList.remove("d-block"); + installPrompt.classList.add("d-none"); } }); } @@ -50,14 +51,15 @@ if ( dismissButton ) { // Function to remember user choice for 7 days function setInstallDismissed() { localStorage.setItem("pwaInstallDismissed", Date.now() + 7 * 24 * 60 * 60 * 1000); - installPrompt.classList.remove("show"); // Hide the prompt + installPrompt.classList.remove("d-block"); // Hide the prompt + installPrompt.classList.add("d-none"); } // Check if the 7-day period has passed if (localStorage.getItem("pwaInstallDismissed")) { const dismissUntil = parseInt(localStorage.getItem("pwaInstallDismissed"), 10); if (Date.now() < dismissUntil) { - installPrompt.classList.remove("show"); // Ensure it's hidden + // } else { localStorage.removeItem("pwaInstallDismissed"); // Reset after 7 days } diff --git a/app/views/pwa.html b/app/views/pwa.html index 13505f6..200ae97 100644 --- a/app/views/pwa.html +++ b/app/views/pwa.html @@ -1,9 +1,9 @@ -