1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-23 15:56:37 +02:00

Add feature to install chat on the home screen

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2024-04-27 19:11:03 +02:00
parent badbb2567e
commit a50e865ef0
10 changed files with 169 additions and 60 deletions

View File

@ -251,4 +251,25 @@ document.addEventListener('DOMContentLoaded', () => {
}
setupSocket()
let deferredPrompt = null
window.addEventListener("beforeinstallprompt", (e) => {
e.preventDefault()
deferredPrompt = e
let btn = document.getElementById('install-app-home-screen')
let alert = document.getElementById('alert-download-chat-app')
btn.classList.remove('d-none')
alert.classList.remove('d-none')
btn.onclick = function () {
deferredPrompt.prompt()
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
deferredPrompt = null
btn.classList.add('d-none')
alert.classList.add('d-none')
}
})
}
})
})