From 44abbeadf395ee28d5d3f157c3248abab6e4ac49 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 21 Jul 2015 20:42:14 +0200 Subject: [PATCH] Better support for infinite scrolling with MAM for MUC. updates #306 --- converse.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/converse.js b/converse.js index e852b6b13..b02e97ca8 100644 --- a/converse.js +++ b/converse.js @@ -2980,11 +2980,12 @@ handleMUCStanza: function (stanza) { var xmlns, xquery, i; var from = stanza.getAttribute('from'); - if (!from || (this.model.get('id') !== from.split("/")[0])) { + var is_mam = $(stanza).find('[xmlns="'+Strophe.NS.MAM+'"]').length > 0; + if (!from || (this.model.get('id') !== from.split("/")[0]) || is_mam) { return true; } if (stanza.nodeName === "message") { - this.onChatRoomMessage(stanza); + _.compose(this.onChatRoomMessage.bind(this), this.showStatusMessages.bind(this))(stanza); } else if (stanza.nodeName === "presence") { xquery = stanza.getElementsByTagName("x"); if (xquery.length > 0) { @@ -3233,12 +3234,13 @@ 303: ___('Your nickname has been changed to: %1$s') }, - showStatusMessages: function ($el, is_self) { + showStatusMessages: function (el, is_self) { /* Check for status codes and communicate their purpose to the user. * Allow user to configure chat room if they are the owner. * See: http://xmpp.org/registrar/mucstatus.html */ - var disconnect_msgs = [], + var $el = $(el), + disconnect_msgs = [], msgs = [], reasons = []; $el.find('x[xmlns="'+Strophe.NS.MUC_USER+'"]').each(function (idx, x) { @@ -3288,7 +3290,8 @@ for (i=0; i