mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40: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').text data.topic
|
||||||
$('#topic').wcfBlindIn() if $('#topic').text().trim() isnt '' and $('#topic').is(':hidden')
|
$('#topic').wcfBlindIn() if $('#topic').text().trim() isnt '' and $('#topic').is(':hidden')
|
||||||
|
|
||||||
$('title').text @titleTemplate.fetch(data)
|
@handleMessages(data.messages)
|
||||||
@getMessages()
|
document.title = @titleTemplate.fetch(data)
|
||||||
, @)
|
, @)
|
||||||
error: () ->
|
error: () ->
|
||||||
# Reload the page to change the room the old fashion-way
|
# Reload the page to change the room the old fashion-way
|
||||||
|
@ -66,8 +66,6 @@ public function readData() {
|
|||||||
$this->readRoom();
|
$this->readRoom();
|
||||||
$this->userData['color'] = \wcf\util\ChatUtil::readUserData('color');
|
$this->userData['color'] = \wcf\util\ChatUtil::readUserData('color');
|
||||||
\wcf\util\ChatUtil::writeUserData(array('roomID' => $this->room->roomID));
|
\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) {
|
if (CHAT_DISPLAY_JOIN_LEAVE) {
|
||||||
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array(
|
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array(
|
||||||
@ -86,6 +84,9 @@ public function readData() {
|
|||||||
$return = $messageAction->getReturnValues();
|
$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->readDefaultSmileys();
|
||||||
$this->readChatVersion();
|
$this->readChatVersion();
|
||||||
}
|
}
|
||||||
@ -173,9 +174,12 @@ public function show() {
|
|||||||
if ($this->useTemplate) exit;
|
if ($this->useTemplate) exit;
|
||||||
@header('Content-type: application/json');
|
@header('Content-type: application/json');
|
||||||
|
|
||||||
|
$messages = array();
|
||||||
|
foreach ($this->newestMessages as $message) $messages[] = $message->jsonify(true);
|
||||||
echo \wcf\util\JSON::encode(array(
|
echo \wcf\util\JSON::encode(array(
|
||||||
'title' => $this->room->getTitle(),
|
'title' => $this->room->getTitle(),
|
||||||
'topic' => WCF::getLanguage()->get($this->room->topic)
|
'topic' => WCF::getLanguage()->get($this->room->topic),
|
||||||
|
'messages' => $messages
|
||||||
));
|
));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user