Commit e1efb604 authored by JC Brand's avatar JC Brand

Bugfix. Previous commit didn't take closed chat boxes into consideration

parent dc31057c
......@@ -2844,6 +2844,7 @@
var $message = $(message);
var buddy_jid, $forwarded, $received,
msgid = $message.attr('id'),
chatbox, resource, roster_item,
message_from = $message.attr('from');
if (message_from === converse.connection.jid) {
// FIXME: Forwarded messages should be sent to specific resources,
......@@ -2859,8 +2860,7 @@
message_from = $message.attr('from');
}
var from = Strophe.getBareJidFromJid(message_from),
to = Strophe.getBareJidFromJid($message.attr('to')),
resource, chatbox, roster_item;
to = Strophe.getBareJidFromJid($message.attr('to'));
if (from == converse.bare_jid) {
// I am the sender, so this must be a forwarded message...
buddy_jid = to;
......@@ -2869,10 +2869,6 @@
buddy_jid = from;
resource = Strophe.getResourceFromJid(message_from);
}
chatbox = this.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) {
......@@ -2881,6 +2877,7 @@
return true;
}
chatbox = this.get(buddy_jid);
if (!chatbox) {
var fullname = roster_item.get('fullname');
fullname = _.isEmpty(fullname)? buddy_jid: fullname;
......@@ -2893,6 +2890,16 @@
'url': roster_item.get('url')
});
}
if (msgid && chatbox.messages.findWhere({msgid: msgid})) {
// FIXME: There's still a bug here..
// If a duplicate message is received just after the chat
// box was closed, then it'll open again (due to it being
// created here above), with now new messages.
// The solution is mostly likely to not let chat boxes show
// automatically when they are created, but to require
// "show" to be called explicitly.
return true; // We already have this message stored.
}
if (!this.isOnlyChatStateNotification($message) && from !== converse.bare_jid) {
playNotification();
}
......
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