fix: if you send message scrollToBottom

isekai-main
Barış Soner Uşaklı 2 years ago
parent 8f6feb0b4e
commit 223c85e44e

@ -85,16 +85,16 @@ define('forum/chats/messages', [
} }
messages.parseMessage(data, function (html) { messages.parseMessage(data, function (html) {
onMessagesParsed(chatContentEl, html); onMessagesParsed(chatContentEl, html, data);
}); });
}; };
function onMessagesParsed(chatContentEl, html) { function onMessagesParsed(chatContentEl, html, msgData) {
const newMessage = $(html); const newMessage = $(html);
const isAtBottom = messages.isAtBottom(chatContentEl); const isAtBottom = messages.isAtBottom(chatContentEl);
newMessage.appendTo(chatContentEl); newMessage.appendTo(chatContentEl);
messages.onMessagesAddedToDom(newMessage); messages.onMessagesAddedToDom(newMessage);
if (isAtBottom) { if (isAtBottom || msgData.self) {
messages.scrollToBottom(chatContentEl); messages.scrollToBottom(chatContentEl);
// remove some message elements if there are too many // remove some message elements if there are too many
const chatMsgEls = chatContentEl.find('[data-mid]'); const chatMsgEls = chatContentEl.find('[data-mid]');

Loading…
Cancel
Save