1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 19:58:25 +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 2d706b2b81
commit a121d1042b
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')
}
})
}
})
})

View File

@ -0,0 +1,21 @@
{
"background_color": "white",
"description": "Chat pour le TFJM²",
"display": "standalone",
"icons": [
{
"src": "tfjm-512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "tfjm-192.png",
"sizes": "192x192",
"type": "image/png"
}
],
"name": "Chat TFJM²",
"short_name": "Chat TFJM²",
"start_url": "/chat/fullscreen/",
"theme_color": "black"
}