mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Show newestMessages when switching room via ajax as well
This commit is contained in:
parent
192a421a19
commit
7fe21df49c
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user