Open channels list by swiping
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
e77cc558de
commit
784002c085
|
@ -260,26 +260,56 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
setupSocket()
|
function setupSwipeOffscreen() {
|
||||||
|
const offcanvas = new bootstrap.Offcanvas(document.getElementById('channelSelector'))
|
||||||
|
|
||||||
let deferredPrompt = null
|
let lastX = null
|
||||||
|
document.addEventListener('touchstart', (event) => {
|
||||||
window.addEventListener("beforeinstallprompt", (e) => {
|
if (event.touches.length === 1)
|
||||||
e.preventDefault()
|
lastX = event.touches[0].clientX
|
||||||
deferredPrompt = e
|
})
|
||||||
let btn = document.getElementById('install-app-home-screen')
|
document.addEventListener('touchmove', (event) => {
|
||||||
let alert = document.getElementById('alert-download-chat-app')
|
if (event.touches.length === 1 && lastX !== null) {
|
||||||
btn.classList.remove('d-none')
|
const diff = event.touches[0].clientX - lastX
|
||||||
alert.classList.remove('d-none')
|
if (diff > window.innerWidth / 10 && lastX < window.innerWidth / 4) {
|
||||||
btn.onclick = function () {
|
offcanvas.show()
|
||||||
deferredPrompt.prompt()
|
lastX = null
|
||||||
deferredPrompt.userChoice.then((choiceResult) => {
|
|
||||||
if (choiceResult.outcome === 'accepted') {
|
|
||||||
deferredPrompt = null
|
|
||||||
btn.classList.add('d-none')
|
|
||||||
alert.classList.add('d-none')
|
|
||||||
}
|
}
|
||||||
})
|
else if (diff < -window.innerWidth / 10) {
|
||||||
}
|
offcanvas.hide()
|
||||||
})
|
lastX = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
document.addEventListener('touchend', () => {
|
||||||
|
lastX = null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupPWAPrompt() {
|
||||||
|
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')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
setupSocket()
|
||||||
|
setupSwipeOffscreen()
|
||||||
|
setupPWAPrompt()
|
||||||
})
|
})
|
||||||
|
|
|
@ -49,13 +49,13 @@
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body d-flex flex-column-reverse flex-grow-0 overflow-y-scroll" id="chat-messages">
|
<div class="card-body d-flex flex-column-reverse flex-grow-0 overflow-y-scroll" id="chat-messages">
|
||||||
|
<ul class="list-group list-group-flush" id="message-list"></ul>
|
||||||
<div class="text-center d-none" id="fetch-previous-messages">
|
<div class="text-center d-none" id="fetch-previous-messages">
|
||||||
<a href="#" class="nav-link" onclick="event.preventDefault(); fetchPreviousMessages()">
|
<a href="#" class="nav-link" onclick="event.preventDefault(); fetchPreviousMessages()">
|
||||||
{% trans "Fetch previous messages…" %}
|
{% trans "Fetch previous messages…" %}
|
||||||
</a>
|
</a>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<ul class="list-group list-group-flush" id="message-list"></ul>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer mt-auto">
|
<div class="card-footer mt-auto">
|
||||||
<form onsubmit="event.preventDefault(); sendMessage()">
|
<form onsubmit="event.preventDefault(); sendMessage()">
|
||||||
|
|
Loading…
Reference in New Issue