Get the time from delayed messages.
This commit is contained in:
parent
e87db946c2
commit
ccf019ea50
20
converse.js
20
converse.js
@ -180,6 +180,7 @@ xmppchat.ChatBoxView = Backbone.View.extend({
|
|||||||
composing = $(message).find('composing'),
|
composing = $(message).find('composing'),
|
||||||
$chat_content = $(this.el).find('.chat-content'),
|
$chat_content = $(this.el).find('.chat-content'),
|
||||||
user_id = Strophe.getNodeFromJid(jid),
|
user_id = Strophe.getNodeFromJid(jid),
|
||||||
|
delayed = $(message).find('delay').length > 0,
|
||||||
fullname = this.model.get('fullname');
|
fullname = this.model.get('fullname');
|
||||||
|
|
||||||
if (xmppchat.xmppstatus.getOwnStatus() === 'offline') {
|
if (xmppchat.xmppstatus.getOwnStatus() === 'offline') {
|
||||||
@ -188,31 +189,36 @@ xmppchat.ChatBoxView = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
if (!body) {
|
if (!body) {
|
||||||
if (composing.length > 0) {
|
if (composing.length > 0) {
|
||||||
this.insertStatusNotification(user_id, 'is typing');
|
this.insertStatusNotification(fullname, 'is typing');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: Some messages might be delayed, we must get the time from the event.
|
|
||||||
xmppchat.messages.ClientStorage.addMessage(jid, body, 'from');
|
xmppchat.messages.ClientStorage.addMessage(jid, body, 'from');
|
||||||
$chat_content.find('div.chat-event').remove();
|
$chat_content.find('div.chat-event').remove();
|
||||||
|
if (delayed) {
|
||||||
|
// XXX: Test properly
|
||||||
|
stamp = $(message).find('delay').attr('stamp');
|
||||||
|
time = (new Date(stamp)).toLocaleTimeString().substring(0,5);
|
||||||
|
} else {
|
||||||
|
time = (new Date()).toLocaleTimeString().substring(0,5);
|
||||||
|
}
|
||||||
match = body.match(/^\/(.*?)(?: (.*))?$/);
|
match = body.match(/^\/(.*?)(?: (.*))?$/);
|
||||||
if ((match) && (match[1] === 'me')) {
|
if ((match) && (match[1] === 'me')) {
|
||||||
$chat_content.append(this.action_template({
|
$chat_content.append(this.action_template({
|
||||||
'sender': 'them',
|
'sender': 'them',
|
||||||
'time': (new Date()).toLocaleTimeString().substring(0,5),
|
'time': time,
|
||||||
'message': body.replace(/^\/me/, '*'+user_id).replace(/<br \/>/g, ""),
|
'message': body.replace(/^\/me/, '*'+user_id).replace(/<br \/>/g, ""),
|
||||||
'username': xmppchat.username,
|
'username': xmppchat.username,
|
||||||
'extra_classes': ($(message).find('delay').length > 0) && 'delayed' || ''
|
'extra_classes': delayed && 'delayed' || ''
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
$chat_content.append(
|
$chat_content.append(
|
||||||
this.message_template({
|
this.message_template({
|
||||||
'sender': 'them',
|
'sender': 'them',
|
||||||
'time': (new Date()).toLocaleTimeString().substring(0,5),
|
'time': time,
|
||||||
'message': body.replace(/<br \/>/g, ""),
|
'message': body.replace(/<br \/>/g, ""),
|
||||||
'username': fullname,
|
'username': fullname,
|
||||||
'extra_classes': ($(message).find('delay').length > 0) && 'delayed' || ''
|
'extra_classes': delayed && 'delayed' || ''
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
$chat_content.scrollTop($chat_content[0].scrollHeight);
|
$chat_content.scrollTop($chat_content[0].scrollHeight);
|
||||||
|
Loading…
Reference in New Issue
Block a user