Bugfix. Don't show duplicate messages.

This commit is contained in:
JC Brand 2014-11-08 15:50:00 +01:00
parent eeec4ebc76
commit dc31057cb9

View File

@ -2724,7 +2724,7 @@
delayed = $message.find('delay').length > 0, delayed = $message.find('delay').length > 0,
subject = $message.children('subject').text(); subject = $message.children('subject').text();
if (this.model.messages.findWhere({msgid: msgid})) { if (msgid && this.model.messages.findWhere({msgid: msgid})) {
return true; // We already have this message stored. return true; // We already have this message stored.
} }
this.showStatusMessages($message); this.showStatusMessages($message);
@ -2843,6 +2843,7 @@
onMessage: function (message) { onMessage: function (message) {
var $message = $(message); var $message = $(message);
var buddy_jid, $forwarded, $received, var buddy_jid, $forwarded, $received,
msgid = $message.attr('id'),
message_from = $message.attr('from'); message_from = $message.attr('from');
if (message_from === converse.connection.jid) { if (message_from === converse.connection.jid) {
// FIXME: Forwarded messages should be sent to specific resources, // FIXME: Forwarded messages should be sent to specific resources,
@ -2869,8 +2870,11 @@
resource = Strophe.getResourceFromJid(message_from); resource = Strophe.getResourceFromJid(message_from);
} }
chatbox = this.get(buddy_jid); chatbox = this.get(buddy_jid);
roster_item = converse.roster.get(buddy_jid); if (msgid && chatbox.messages.findWhere({msgid: msgid})) {
return true; // We already have this message stored.
}
roster_item = converse.roster.get(buddy_jid);
if (roster_item === undefined) { if (roster_item === undefined) {
// The buddy was likely removed // The buddy was likely removed
converse.log('Could not get roster item for JID '+buddy_jid, 'error'); converse.log('Could not get roster item for JID '+buddy_jid, 'error');