From 85b16aec0a1696c4790c28a284e7d61946720408 Mon Sep 17 00:00:00 2001 From: Pierre Date: Mon, 26 Jun 2017 10:49:53 +0200 Subject: [PATCH] Messages automaticaly go bottom --- .../components/conversations/chatWindows.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/assets/js/components/conversations/chatWindows.js b/assets/js/components/conversations/chatWindows.js index 0d8eab94..39bf8b81 100644 --- a/assets/js/components/conversations/chatWindows.js +++ b/assets/js/components/conversations/chatWindows.js @@ -692,8 +692,6 @@ ComunicWeb.components.conversations.chatWindows = { */ addMessage: function(conversationID, messageInfos){ - console.log(messageInfos); - //First, check if the conversation informations can be found if(!this.__conversationsCache["conversation-"+conversationID]){ ComunicWeb.debug.logMessage("Conversation Chat Windows : Error ! Couldn't add a message to the conversation because the conversation was not found !"); @@ -708,7 +706,7 @@ ComunicWeb.components.conversations.chatWindows = { //Create message element var messageElem = createElem2({ - insertAsFirstChild: convInfos.box.messagesArea, + appendTo: convInfos.box.messagesArea, type: "div", class: "direct-chat-msg " + (userIsPoster ? "right" : "") }); @@ -728,6 +726,10 @@ ComunicWeb.components.conversations.chatWindows = { innerHTML: "Loading", }); + //Hide user name if it is the current user + if(userIsPoster) + usernameElem.style.display = "none"; + //Add user account image var userAccountImage = createElem2({ appendTo: messageElem, @@ -772,6 +774,17 @@ ComunicWeb.components.conversations.chatWindows = { userAccountImage.src = userInfos.accountImage; } + //Enable (again) slimscrool + $(convInfos.box.messagesArea).slimscroll({ + height: "250px", + }); + + //Scroll to the bottom of the conversation + var scrollBottom = $(convInfos.box.messagesArea).prop("scrollHeight")+"px"; + $(convInfos.box.messagesArea).slimScroll({ + scrollTo: scrollBottom + }); + //Success return true; },