diff --git a/frontend/public/js/app.js b/frontend/public/js/app.js index 3fc4986..4e4fd04 100644 --- a/frontend/public/js/app.js +++ b/frontend/public/js/app.js @@ -116,22 +116,22 @@ function renderLanding() { const btn = app.querySelector('[data-install-btn]'); const hint = app.querySelector('[data-install-hint]'); - if (deferredInstallPrompt) { - wrap.hidden = false; - btn.addEventListener('click', async () => { + // Show immediately if we already have the prompt or are on iOS + if (deferredInstallPrompt || isIOS) wrap.hidden = false; + + // Always attach handler — check state at click time (handles async beforeinstallprompt) + btn.addEventListener('click', async () => { + if (deferredInstallPrompt) { deferredInstallPrompt.prompt(); const { outcome } = await deferredInstallPrompt.userChoice; if (outcome === 'accepted') { deferredInstallPrompt = null; wrap.hidden = true; } - }); - } else if (isIOS) { - wrap.hidden = false; - btn.addEventListener('click', () => { + } else if (isIOS) { hint.hidden = !hint.hidden; - }); - } + } + }); } /* ---------- Render: route page ---------- */