Commit 1c3a5a94 authored by JC Brand's avatar JC Brand

Don't store chatroom messages, the XMPP server (ejabberd) does this already.

parent e964e972
...@@ -836,12 +836,6 @@ ...@@ -836,12 +836,6 @@
break; break;
default: default:
this.last_msgid = xmppchat.connection.muc.groupchat(this.model.get('jid'), body); this.last_msgid = xmppchat.connection.muc.groupchat(this.model.get('jid'), body);
this.model.messages.create({
fullname: 'me',
sender: 'me',
time: (new Date()).toLocaleTimeString().substring(0,5),
message: body
});
break; break;
} }
}, },
...@@ -919,51 +913,41 @@ ...@@ -919,51 +913,41 @@
var $message = $(message), var $message = $(message),
body = $message.children('body').text(), body = $message.children('body').text(),
jid = $message.attr('from'), jid = $message.attr('from'),
composing = $message.find('composing'),
$chat_content = this.$el.find('.chat-content'), $chat_content = this.$el.find('.chat-content'),
sender = Strophe.unescapeNode(Strophe.getResourceFromJid(jid)), sender = Strophe.unescapeNode(Strophe.getResourceFromJid(jid)),
delayed = $message.find('delay').length > 0,
subject = $message.children('subject').text(), subject = $message.children('subject').text(),
match; match, template;
if (!body) { return true; } // XXX: Necessary?
if (subject) { if (subject) {
this.$el.find('.chatroom-topic').text(subject).attr('title', subject); this.$el.find('.chatroom-topic').text(subject).attr('title', subject);
} }
if (!body) { if (delayed) {
if (composing.length) { stamp = $message.find('delay').attr('stamp');
this.insertStatusNotification(sender+' '+'is typing'); time = (new Date(stamp)).toLocaleTimeString().substring(0,5);
return true;
}
} else {
if (sender === this.model.get('nick')) {
// Our own message which is already appended
return true;
} else { } else {
$chat_content.find('div.chat-event').remove(); time = (new Date()).toLocaleTimeString().substring(0,5);
}
match = body.match(/^\/(.*?)(?: (.*))?$/); match = body.match(/^\/(.*?)(?: (.*))?$/);
if ((match) && (match[1] === 'me')) { if ((match) && (match[1] === 'me')) {
body = body.replace(/^\/me/, '*'+sender); body = body.replace(/^\/me/, '*'+sender);
$chat_content.append( template = this.action_template;
this.action_template({
'sender': 'room',
'time': (new Date()).toLocaleTimeString().substring(0,5),
'message': body,
'username': sender,
'extra_classes': ($message.find('delay').length > 0) && 'delayed' || ''
}));
} else { } else {
template = this.message_template;
}
if (sender === this.model.get('nick')) {
sender = 'me';
}
$chat_content.append( $chat_content.append(
this.message_template({ template({
'sender': 'room', 'sender': sender == 'me' && sender || 'room',
'time': (new Date()).toLocaleTimeString().substring(0,5), 'time': time,
'message': body, 'message': body,
'username': sender, 'username': sender,
'extra_classes': ($message.find('delay').length > 0) && 'delayed' || '' 'extra_classes': delayed && 'delayed' || ''
})); })
} );
$chat_content.scrollTop($chat_content[0].scrollHeight); this.scrollDown();
}
}
return true; return true;
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment