Fixes chat messages timestamp according to XEP-0203. Fixes #305.
This commit is contained in:
parent
6a492d96c2
commit
7a54537bee
|
@ -138,10 +138,10 @@ function setupListeners() {
|
|||
APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_JOINED, function (from) {
|
||||
API.triggerEvent("participantJoined", {jid: from});
|
||||
});
|
||||
APP.xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, function (from, nick, txt, myjid) {
|
||||
APP.xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, function (from, nick, txt, myjid, stamp) {
|
||||
if (from != myjid)
|
||||
API.triggerEvent("incomingMessage",
|
||||
{"from": from, "nick": nick, "message": txt});
|
||||
{"from": from, "nick": nick, "message": txt, "stamp": stamp});
|
||||
});
|
||||
APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_LEFT, function (jid) {
|
||||
API.triggerEvent("participantLeft", {jid: jid});
|
||||
|
|
|
@ -408,9 +408,9 @@ function chatSetSubject(text)
|
|||
return Chat.chatSetSubject(text);
|
||||
};
|
||||
|
||||
function updateChatConversation(from, displayName, message) {
|
||||
return Chat.updateChatConversation(from, displayName, message);
|
||||
};
|
||||
function updateChatConversation(from, displayName, message, myjid, stamp) {
|
||||
return Chat.updateChatConversation(from, displayName, message, myjid, stamp);
|
||||
}
|
||||
|
||||
function onMucJoined(jid, info) {
|
||||
Toolbar.updateRoomUrl(window.location.href);
|
||||
|
|
|
@ -85,8 +85,8 @@ function setVisualNotification(show) {
|
|||
* Returns the current time in the format it is shown to the user
|
||||
* @returns {string}
|
||||
*/
|
||||
function getCurrentTime() {
|
||||
var now = new Date();
|
||||
function getCurrentTime(stamp) {
|
||||
var now = (stamp? new Date(stamp): new Date());
|
||||
var hour = now.getHours();
|
||||
var minute = now.getMinutes();
|
||||
var second = now.getSeconds();
|
||||
|
@ -228,7 +228,7 @@ var Chat = (function (my) {
|
|||
/**
|
||||
* Appends the given message to the chat conversation.
|
||||
*/
|
||||
my.updateChatConversation = function (from, displayName, message) {
|
||||
my.updateChatConversation = function (from, displayName, message, myjid, stamp) {
|
||||
var divClassName = '';
|
||||
|
||||
if (APP.xmpp.myJid() === from) {
|
||||
|
@ -256,7 +256,7 @@ var Chat = (function (my) {
|
|||
'<div class="chatmessage">'+
|
||||
'<img src="../images/chatArrow.svg" class="chatArrow">' +
|
||||
'<div class="username ' + divClassName +'">' + escDisplayName +
|
||||
'</div>' + '<div class="timestamp">' + getCurrentTime() +
|
||||
'</div>' + '<div class="timestamp">' + getCurrentTime(stamp) +
|
||||
'</div>' + '<div class="usermessage">' + message + '</div>' +
|
||||
'</div>';
|
||||
|
||||
|
|
|
@ -389,7 +389,7 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
if (txt) {
|
||||
console.log('chat', nick, txt);
|
||||
eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
|
||||
from, nick, txt, this.myroomjid);
|
||||
from, nick, txt, this.myroomjid, $(msg).find('>delay').attr('stamp'));
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue