mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Adding ID to each message, ensure every message is shown only once
This commit is contained in:
parent
3243f82f07
commit
3ae3909b55
@ -118,11 +118,11 @@ consoleMock ?=
|
|||||||
|
|
||||||
# Clears the stream
|
# Clears the stream
|
||||||
$('#timsChatClear').click (event) ->
|
$('#timsChatClear').click (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
$('.timsChatMessage').remove()
|
$('.timsChatMessage').remove()
|
||||||
@oldScrollTop = $('.timsChatMessageContainer').scrollTop()
|
@oldScrollTop = $('.timsChatMessageContainer').scrollTop()
|
||||||
$('.timsChatMessageContainer').scrollTop $('.timsChatMessageContainer ul').height()
|
$('.timsChatMessageContainer').scrollTop $('.timsChatMessageContainer ul').height()
|
||||||
$('#timsChatInput').focus()
|
$('#timsChatInput').focus()
|
||||||
|
|
||||||
# Toggle Buttons
|
# Toggle Buttons
|
||||||
$('.timsChatToggle').click (event) ->
|
$('.timsChatToggle').click (event) ->
|
||||||
@ -252,10 +252,12 @@ consoleMock ?=
|
|||||||
|
|
||||||
# Insert the messages
|
# Insert the messages
|
||||||
for message in messages
|
for message in messages
|
||||||
|
continue if $.wcfIsset 'timsChatMessage'+message.messageID # Prevent problems with race condition
|
||||||
@events.newMessage.fire message
|
@events.newMessage.fire message
|
||||||
|
|
||||||
output = @messageTemplate.fetch message
|
output = @messageTemplate.fetch message
|
||||||
li = $ '<li></li>'
|
li = $ '<li></li>'
|
||||||
|
li.attr 'id', 'timsChatMessage'+message.messageID
|
||||||
li.addClass 'timsChatMessage timsChatMessage'+message.type
|
li.addClass 'timsChatMessage timsChatMessage'+message.type
|
||||||
li.addClass 'ownMessage' if message.sender is WCF.User.userID
|
li.addClass 'ownMessage' if message.sender is WCF.User.userID
|
||||||
li.append output
|
li.append output
|
||||||
|
@ -103,7 +103,8 @@ public function jsonify($raw = false) {
|
|||||||
'time' => $this->time,
|
'time' => $this->time,
|
||||||
'receiver' => $this->receiver,
|
'receiver' => $this->receiver,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'roomID' => $this->roomID
|
'roomID' => $this->roomID,
|
||||||
|
'messageID' => $this->messageID
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($raw) return $array;
|
if ($raw) return $array;
|
||||||
|
Loading…
Reference in New Issue
Block a user