From 3ae3909b55e4eb34a37c4960463299f5b87f4fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 5 Feb 2012 19:06:00 +0100 Subject: [PATCH] Adding ID to each message, ensure every message is shown only once --- file/js/TimWolla.WCF.Chat.coffee | 12 +++++++----- file/lib/data/chat/message/ChatMessage.class.php | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 8b81072..9a5f777 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -118,11 +118,11 @@ consoleMock ?= # Clears the stream $('#timsChatClear').click (event) -> - event.preventDefault() - $('.timsChatMessage').remove() - @oldScrollTop = $('.timsChatMessageContainer').scrollTop() - $('.timsChatMessageContainer').scrollTop $('.timsChatMessageContainer ul').height() - $('#timsChatInput').focus() + event.preventDefault() + $('.timsChatMessage').remove() + @oldScrollTop = $('.timsChatMessageContainer').scrollTop() + $('.timsChatMessageContainer').scrollTop $('.timsChatMessageContainer ul').height() + $('#timsChatInput').focus() # Toggle Buttons $('.timsChatToggle').click (event) -> @@ -252,10 +252,12 @@ consoleMock ?= # Insert the messages for message in messages + continue if $.wcfIsset 'timsChatMessage'+message.messageID # Prevent problems with race condition @events.newMessage.fire message output = @messageTemplate.fetch message li = $ '
  • ' + li.attr 'id', 'timsChatMessage'+message.messageID li.addClass 'timsChatMessage timsChatMessage'+message.type li.addClass 'ownMessage' if message.sender is WCF.User.userID li.append output diff --git a/file/lib/data/chat/message/ChatMessage.class.php b/file/lib/data/chat/message/ChatMessage.class.php index 011596b..f300148 100755 --- a/file/lib/data/chat/message/ChatMessage.class.php +++ b/file/lib/data/chat/message/ChatMessage.class.php @@ -103,7 +103,8 @@ public function jsonify($raw = false) { 'time' => $this->time, 'receiver' => $this->receiver, 'type' => $this->type, - 'roomID' => $this->roomID + 'roomID' => $this->roomID, + 'messageID' => $this->messageID ); if ($raw) return $array;