diff --git a/public/src/client/chats.js b/public/src/client/chats.js index 68ee5bf98a..d9b309bd5d 100644 --- a/public/src/client/chats.js +++ b/public/src/client/chats.js @@ -125,8 +125,9 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll', }; function onMessagesParsed(html) { - var newMessage = $(html); - newMessage.insertBefore($('.user-typing')); + var newMessage = $(html), + chatContainer = $('.chat-content'); + newMessage.appendTo(chatContainer); newMessage.find('.timeago').timeago(); newMessage.find('img:not(".chat-user-image")').addClass('img-responsive'); Chats.scrollToBottom($('.expanded-chat .chat-content')); diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index da4efcafd5..8d2fe2217b 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -80,7 +80,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra if (modal.is(":visible")) { taskbar.updateActive(modal.attr('UUID')); - Chats.scrollToBottom(modal.find('#chat-content')); + Chats.scrollToBottom(modal.find('.chat-content')); } else { module.toggleNew(modal.attr('UUID'), true, true); } @@ -111,7 +111,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra socket.on('event:chats.userStartTyping', function(withUid) { var modal = module.getModal(withUid); - var chatContent = modal.find('#chat-content'); + var chatContent = modal.find('.chat-content'); if (!chatContent.length) { return; } @@ -234,7 +234,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra return; } - chatModal.find('#chat-content').css('height', module.calculateChatListHeight(chatModal)); + chatModal.find('.chat-content').css('height', module.calculateChatListHeight(chatModal)); }); chatModal.draggable({ @@ -373,7 +373,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra chatModal.removeClass('hide'); checkStatus(chatModal); taskbar.updateActive(uuid); - Chats.scrollToBottom(chatModal.find('#chat-content')); + Chats.scrollToBottom(chatModal.find('.chat-content')); module.bringModalToTop(chatModal); module.focusInput(chatModal); socket.emit('modules.chats.markRead', chatModal.attr('touid')); @@ -387,7 +387,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra module.enableMobileBehaviour = function(modalEl) { app.toggleNavbar(false); modalEl.attr('data-mobile', '1'); - var messagesEl = modalEl.find('#chat-content'); + var messagesEl = modalEl.find('.chat-content'); messagesEl.css('height', module.calculateChatListHeight(modalEl)); $(window).on('resize', function() { @@ -402,7 +402,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra module.calculateChatListHeight = function(modalEl) { var totalHeight = modalEl.find('.modal-content').outerHeight() - modalEl.find('.modal-header').outerHeight(), padding = parseInt(modalEl.find('.modal-body').css('padding-top'), 10) + parseInt(modalEl.find('.modal-body').css('padding-bottom'), 10), - contentMargin = parseInt(modalEl.find('#chat-content').css('margin-top'), 10) + parseInt(modalEl.find('#chat-content').css('margin-bottom'), 10), + contentMargin = parseInt(modalEl.find('.chat-content').css('margin-top'), 10) + parseInt(modalEl.find('.chat-content').css('margin-bottom'), 10), sinceHeight = modalEl.find('.since-bar').outerHeight(true), inputGroupHeight = modalEl.find('.input-group').outerHeight(); @@ -426,7 +426,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra function loadChatSince(chatModal, since, callback) { socket.emit('modules.chats.get', {touid: chatModal.attr('touid'), since: since}, function(err, messages) { - var chatContent = chatModal.find('#chat-content'); + var chatContent = chatModal.find('.chat-content'); chatContent.find('.chat-message').remove(); module.appendChatMessage(chatModal, messages, callback); }); @@ -457,7 +457,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra } module.appendChatMessage = function(chatModal, data, done) { - var chatContent = chatModal.find('#chat-content'); + var chatContent = chatModal.find('.chat-content'); Chats.parseMessage(data, function(html) { var message = $(html); diff --git a/src/messaging.js b/src/messaging.js index 9edd99d836..bb1ce85182 100644 --- a/src/messaging.js +++ b/src/messaging.js @@ -164,6 +164,9 @@ var db = require('./database'), if (index > 0 && parseInt(message.timestamp, 10) > parseInt(messages[index-1].timestamp, 10) + (1000*60*5)) { // If it's been 5 minutes, this is a new set of messages message.newSet = true; + } else if (index > 0 && message.fromuid !== messages[index-1].fromuid) { + // If the previous message was from the other person, this is also a new set + message.newSet = true } return message;