diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index e1caf01..8fd51eb 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -173,8 +173,8 @@ TimWolla.WCF ?= {} $('#topic').text data.topic $('#topic').wcfBlindIn() if $('#topic').text().trim() isnt '' and $('#topic').is(':hidden') - $('title').text @titleTemplate.fetch(data) - @getMessages() + @handleMessages(data.messages) + document.title = @titleTemplate.fetch(data) , @) error: () -> # Reload the page to change the room the old fashion-way diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php index a3922fb..5bab350 100644 --- a/file/lib/page/ChatPage.class.php +++ b/file/lib/page/ChatPage.class.php @@ -66,8 +66,6 @@ public function readData() { $this->readRoom(); $this->userData['color'] = \wcf\util\ChatUtil::readUserData('color'); \wcf\util\ChatUtil::writeUserData(array('roomID' => $this->room->roomID)); - $this->newestMessages = chat\message\ChatMessageList::getNewestMessages($this->room, CHAT_LASTMESSAGES); - \wcf\util\ChatUtil::writeUserData(array('lastSeen' => count($this->newestMessages) ? end($this->newestMessages)->messageID : 0)); if (CHAT_DISPLAY_JOIN_LEAVE) { $messageAction = new chat\message\ChatMessageAction(array(), 'create', array( @@ -86,6 +84,9 @@ public function readData() { $return = $messageAction->getReturnValues(); } + $this->newestMessages = chat\message\ChatMessageList::getNewestMessages($this->room, CHAT_LASTMESSAGES); + \wcf\util\ChatUtil::writeUserData(array('lastSeen' => end($this->newestMessages)->messageID)); + $this->readDefaultSmileys(); $this->readChatVersion(); } @@ -173,9 +174,12 @@ public function show() { if ($this->useTemplate) exit; @header('Content-type: application/json'); + $messages = array(); + foreach ($this->newestMessages as $message) $messages[] = $message->jsonify(true); echo \wcf\util\JSON::encode(array( 'title' => $this->room->getTitle(), - 'topic' => WCF::getLanguage()->get($this->room->topic) + 'topic' => WCF::getLanguage()->get($this->room->topic), + 'messages' => $messages )); exit; }