bugfixes
This commit is contained in:
@ -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
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
<div class="container pt-4 fade show" id="install-prompt">
|
||||
<div class="container pt-4 d-none" id="install-prompt">
|
||||
<div class="row">
|
||||
<div class="alert alert-success alert-dismissible w-100" role="alert">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
{SITENAME} is now available as a Progressive Web App, click the button to install now.
|
||||
<button class="btn btn-md btn-outline-primary me-3" id="install-button">Install App</button>
|
||||
<button class="btn btn-md btn-outline-primary mx-2" id="install-button">Install App</button>
|
||||
</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
BIN
images/icon-maskWhite.png
Normal file
BIN
images/icon-maskWhite.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
Reference in New Issue
Block a user