mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-23 03:58:25 +02:00
Automatically scroll to bottom
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -95,8 +95,18 @@ function setChannels(new_channels) {
|
||||
}
|
||||
|
||||
function receiveMessage(message) {
|
||||
let scrollableContent = document.getElementById('chat-messages')
|
||||
let isScrolledToBottom = scrollableContent.scrollHeight - scrollableContent.clientHeight <= scrollableContent.scrollTop + 1
|
||||
|
||||
messages[message['channel_id']].set(message['id'], message)
|
||||
redrawMessages()
|
||||
|
||||
// Scroll to bottom if the user was already at the bottom
|
||||
if (isScrolledToBottom)
|
||||
scrollableContent.scrollTop = scrollableContent.scrollHeight - scrollableContent.clientHeight
|
||||
|
||||
if (message['content'].includes("@everyone"))
|
||||
showNotification(channels[message['channel_id']]['name'], `${message['author']} : ${message['content']}`)
|
||||
}
|
||||
|
||||
function fetchMessages(channel_id, offset = 0, limit = MAX_MESSAGES) {
|
||||
|
Reference in New Issue
Block a user