Fix bug where new chat messages would not append

... due to incorrect class and id assignment of the chat modal. Regression was caused by an earlier commit that moved the
typing span elsewhere.
v1.18.x
Julian Lam 10 years ago
parent 81dc2b9615
commit 2593f1b4d9

@ -125,8 +125,9 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
}; };
function onMessagesParsed(html) { function onMessagesParsed(html) {
var newMessage = $(html); var newMessage = $(html),
newMessage.insertBefore($('.user-typing')); chatContainer = $('.chat-content');
newMessage.appendTo(chatContainer);
newMessage.find('.timeago').timeago(); newMessage.find('.timeago').timeago();
newMessage.find('img:not(".chat-user-image")').addClass('img-responsive'); newMessage.find('img:not(".chat-user-image")').addClass('img-responsive');
Chats.scrollToBottom($('.expanded-chat .chat-content')); Chats.scrollToBottom($('.expanded-chat .chat-content'));

@ -80,7 +80,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
if (modal.is(":visible")) { if (modal.is(":visible")) {
taskbar.updateActive(modal.attr('UUID')); taskbar.updateActive(modal.attr('UUID'));
Chats.scrollToBottom(modal.find('#chat-content')); Chats.scrollToBottom(modal.find('.chat-content'));
} else { } else {
module.toggleNew(modal.attr('UUID'), true, true); 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) { socket.on('event:chats.userStartTyping', function(withUid) {
var modal = module.getModal(withUid); var modal = module.getModal(withUid);
var chatContent = modal.find('#chat-content'); var chatContent = modal.find('.chat-content');
if (!chatContent.length) { if (!chatContent.length) {
return; return;
} }
@ -234,7 +234,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
return; return;
} }
chatModal.find('#chat-content').css('height', module.calculateChatListHeight(chatModal)); chatModal.find('.chat-content').css('height', module.calculateChatListHeight(chatModal));
}); });
chatModal.draggable({ chatModal.draggable({
@ -373,7 +373,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
chatModal.removeClass('hide'); chatModal.removeClass('hide');
checkStatus(chatModal); checkStatus(chatModal);
taskbar.updateActive(uuid); taskbar.updateActive(uuid);
Chats.scrollToBottom(chatModal.find('#chat-content')); Chats.scrollToBottom(chatModal.find('.chat-content'));
module.bringModalToTop(chatModal); module.bringModalToTop(chatModal);
module.focusInput(chatModal); module.focusInput(chatModal);
socket.emit('modules.chats.markRead', chatModal.attr('touid')); 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) { module.enableMobileBehaviour = function(modalEl) {
app.toggleNavbar(false); app.toggleNavbar(false);
modalEl.attr('data-mobile', '1'); modalEl.attr('data-mobile', '1');
var messagesEl = modalEl.find('#chat-content'); var messagesEl = modalEl.find('.chat-content');
messagesEl.css('height', module.calculateChatListHeight(modalEl)); messagesEl.css('height', module.calculateChatListHeight(modalEl));
$(window).on('resize', function() { $(window).on('resize', function() {
@ -402,7 +402,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
module.calculateChatListHeight = function(modalEl) { module.calculateChatListHeight = function(modalEl) {
var totalHeight = modalEl.find('.modal-content').outerHeight() - modalEl.find('.modal-header').outerHeight(), 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), 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), sinceHeight = modalEl.find('.since-bar').outerHeight(true),
inputGroupHeight = modalEl.find('.input-group').outerHeight(); inputGroupHeight = modalEl.find('.input-group').outerHeight();
@ -426,7 +426,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
function loadChatSince(chatModal, since, callback) { function loadChatSince(chatModal, since, callback) {
socket.emit('modules.chats.get', {touid: chatModal.attr('touid'), since: since}, function(err, messages) { 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(); chatContent.find('.chat-message').remove();
module.appendChatMessage(chatModal, messages, callback); module.appendChatMessage(chatModal, messages, callback);
}); });
@ -457,7 +457,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
} }
module.appendChatMessage = function(chatModal, data, done) { module.appendChatMessage = function(chatModal, data, done) {
var chatContent = chatModal.find('#chat-content'); var chatContent = chatModal.find('.chat-content');
Chats.parseMessage(data, function(html) { Chats.parseMessage(data, function(html) {
var message = $(html); var message = $(html);

@ -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 (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 // If it's been 5 minutes, this is a new set of messages
message.newSet = true; 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; return message;

Loading…
Cancel
Save