Surface install-prompt failures instead of failing silently

This commit is contained in:
Barely Removable 2026-08-22 09:40:43 -07:00
parent 6b247794db
commit 27a6b49b37

View file

@ -572,9 +572,18 @@ window.addEventListener('beforeinstallprompt', (e) => {
document.addEventListener('click', async (e) => {
if (!e.target.closest('#btn-install')) return;
if (!deferredInstall) return;
deferredInstall.prompt();
await deferredInstall.userChoice;
if (!deferredInstall) {
banner("No install prompt available — try Chrome's own menu (⋮ → Install app) instead.", true);
return;
}
try {
await deferredInstall.prompt();
const choice = await deferredInstall.userChoice;
if (choice.outcome !== 'accepted') banner(`Install ${choice.outcome}.`);
} catch (err) {
banner(`Install failed: ${err.message}`, true);
} finally {
deferredInstall = null;
$('#btn-install').hidden = true;
}
});