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 // src/pwaInstall.js
let deferredPrompt = null; 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) => { window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault(); e.preventDefault();
deferredPrompt = e; 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" // Fonction appelée par le bouton "Install"
export function promptInstall() { export function promptInstall() {
if (deferredPrompt) { if (deferredPrompt && !promptShown) {
console.log('PWA: Triggering native install prompt'); console.log('PWA: Triggering native prompt');
deferredPrompt.prompt(); deferredPrompt.prompt();
promptShown = true;
deferredPrompt.userChoice.then((choiceResult) => { deferredPrompt.userChoice.then((choiceResult) => {
console.log('PWA Install outcome:', choiceResult.outcome); console.log('PWA Install outcome:', choiceResult.outcome);
deferredPrompt = null; deferredPrompt = null;
}); });
} else { } else {
console.log('PWA: No prompt ready yet - interact with the site (scroll, click)'); console.log('PWA: No prompt ready - scroll/click more on the site');
alert('PWA not ready yet. Try scrolling, clicking filters or markers, then click Install again.'); alert('PWA not ready yet. Try scrolling the map, clicking filters or markers, then click Install again.');
} }
} }