1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Merge similar messages together

This commit is contained in:
Tim Düsterhus 2013-06-23 19:46:50 +02:00
parent f313dde2c3
commit 42ef646685

View File

@ -35,6 +35,8 @@ exposed by a function if necessary.
chatSession = Date.now() chatSession = Date.now()
errorVisible = false errorVisible = false
lastMessage = null
remainingFailures = 3 remainingFailures = 3
events = events =
@ -411,7 +413,13 @@ Insert the given messages into the chat stream.
for message in messages for message in messages
events.newMessage.fire message events.newMessage.fire message
createNewMessage = yes
if $('.timsChatMessage:last-child .text').is('ul') and lastMessage isnt null and lastMessage.type in [ 0, 7 ]
if lastMessage.type is message.type and lastMessage.sender is message.sender and lastMessage.receiver is message.receiver
createNewMessage = no
output = v.messageTemplate.fetch message output = v.messageTemplate.fetch message
if createNewMessage
li = $ '<li></li>' li = $ '<li></li>'
li.addClass 'timsChatMessage' li.addClass 'timsChatMessage'
li.addClass "timsChatMessage#{message.type}" li.addClass "timsChatMessage#{message.type}"
@ -420,7 +428,10 @@ Insert the given messages into the chat stream.
li.append output li.append output
li.appendTo $ '#timsChatMessageContainer > ul' li.appendTo $ '#timsChatMessageContainer > ul'
else
$('.timsChatMessage:last-child .text').append $(output).find('.text li:last-child')
lastMessage = message
$('#timsChatMessageContainer').scrollTop $('#timsChatMessageContainer').prop('scrollHeight') if $('#timsChatAutoscroll').data('status') is 1 $('#timsChatMessageContainer').scrollTop $('#timsChatMessageContainer').prop('scrollHeight') if $('#timsChatAutoscroll').data('status') is 1
Rebuild the userlist based on the given `users`. Rebuild the userlist based on the given `users`.