update frontend

This commit is contained in:
Your Name 2025-12-21 20:19:33 -05:00
parent dee963cd0e
commit 4d2f81f434
1 changed files with 8 additions and 6 deletions

View File

@ -1,24 +1,26 @@
// src/pwaInstall.js
let deferredPrompt = null;
let promptShown = false;
// Stocke l'événement natif quand Chrome le déclenche (après interactions)
// Stocke l'événement natif (se déclenche après interactions)
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
deferredPrompt = e;
console.log('PWA: Install prompt ready - waiting for user click on button');
console.log('PWA: Install prompt ready - button can trigger it now');
});
// Fonction appelée par le bouton "Install"
export function promptInstall() {
if (deferredPrompt) {
console.log('PWA: Triggering native install prompt');
if (deferredPrompt && !promptShown) {
console.log('PWA: Triggering native prompt');
deferredPrompt.prompt();
promptShown = true;
deferredPrompt.userChoice.then((choiceResult) => {
console.log('PWA Install outcome:', choiceResult.outcome);
deferredPrompt = null;
});
} else {
console.log('PWA: No prompt ready yet - interact with the site (scroll, click)');
alert('PWA not ready yet. Try scrolling, clicking filters or markers, then click Install again.');
console.log('PWA: No prompt ready - scroll/click more on the site');
alert('PWA not ready yet. Try scrolling the map, clicking filters or markers, then click Install again.');
}
}