diff --git a/converse.js b/converse.js index bb7098d14..45e0d0348 100644 --- a/converse.js +++ b/converse.js @@ -1511,6 +1511,20 @@ return 0; }, + subscribeBack: function (jid) { + // XXX: Why the distinction between jid and bare_jid? + var bare_jid = Strophe.getBareJidFromJid(jid) + if (xmppchat.connection.roster.findItem(bare_jid)) { + xmppchat.connection.roster.authorize(bare_jid); + xmppchat.connection.roster.subscribe(jid); + } else { + xmppchat.connection.roster.add(jid, '', [], function (iq) { + xmppchat.connection.roster.authorize(bare_jid); + xmppchat.connection.roster.subscribe(jid); + }); + } + }, + getNumOnlineContacts: function () { var count = 0, models = this.models, @@ -1582,15 +1596,7 @@ // TODO see if auto_subscribe is truly an unresolved variable if (xmppchat.auto_subscribe) { if ((!item) || (item.get('subscription') != 'to')) { - if (xmppchat.connection.roster.findItem(bare_jid)) { - xmppchat.connection.roster.authorize(bare_jid); - xmppchat.connection.roster.subscribe(jid); - } else { - xmppchat.connection.roster.add(jid, '', [], function (iq) { - xmppchat.connection.roster.authorize(bare_jid); - xmppchat.connection.roster.subscribe(jid); - }); - } + this.subscribeBack(jid); } else { xmppchat.connection.roster.authorize(bare_jid); } @@ -1675,8 +1681,7 @@ delete this.rosteritemviews[item.id]; }, this); - this.$el.hide() - .html(this.template()); + this.$el.html(this.template()); }, template: _.template('