pwa upgrades

This commit is contained in:
osiu97
2026-07-08 19:07:06 +02:00
parent a321e8dd4c
commit b7effd52de
2 changed files with 39 additions and 0 deletions
+28
View File
@@ -116,9 +116,37 @@ const HomeSection = {
};
BLE.on('connected', update);
BLE.on('disconnected', update);
// PWA Install Logic
const pwaCard = container.querySelector('#home-pwa-install-card');
const pwaBtn = container.querySelector('#home-btn-install-pwa');
const checkPwaStatus = () => {
if (window.deferredPrompt && pwaCard) {
pwaCard.style.display = 'block';
}
};
// Check initially in case the event fired before we mounted
checkPwaStatus();
window.addEventListener('pwa-installable', checkPwaStatus);
if (pwaBtn) {
pwaBtn.addEventListener('click', async () => {
if (!window.deferredPrompt) return;
window.deferredPrompt.prompt();
const { outcome } = await window.deferredPrompt.userChoice;
console.log(`User response to the install prompt: ${outcome}`);
window.deferredPrompt = null;
pwaCard.style.display = 'none';
});
}
this._cleanup = [
() => BLE.off('connected', update),
() => BLE.off('disconnected', update),
() => window.removeEventListener('pwa-installable', checkPwaStatus),
];
},