Commit d8e4f848 authored by ichim-david's avatar ichim-david

Wrap this with jQuery only once in subscribeToSuggestedItems; Same thing with...

Wrap this with jQuery only once in subscribeToSuggestedItems; Same thing with presence in presenceHandler
parent 58bbbe8b
...@@ -1390,9 +1390,10 @@ ...@@ -1390,9 +1390,10 @@
subscribeToSuggestedItems: function (msg) { subscribeToSuggestedItems: function (msg) {
$(msg).find('item').each(function () { $(msg).find('item').each(function () {
var jid = $(this).attr('jid'), var $this = $(this),
action = $(this).attr('action'), jid = $this.attr('jid'),
fullname = $(this).attr('name'); action = $this.attr('action'),
fullname = $this.attr('name');
if (action === 'add') { if (action === 'add') {
xmppchat.connection.roster.add(jid, fullname, [], function (iq) { xmppchat.connection.roster.add(jid, fullname, [], function (iq) {
xmppchat.connection.roster.subscribe(jid); xmppchat.connection.roster.subscribe(jid);
...@@ -1498,12 +1499,13 @@ ...@@ -1498,12 +1499,13 @@
}, },
presenceHandler: function (presence) { presenceHandler: function (presence) {
var jid = $(presence).attr('from'), var $presence = $(presence),
jid = $presence.attr('from'),
bare_jid = Strophe.getBareJidFromJid(jid), bare_jid = Strophe.getBareJidFromJid(jid),
resource = Strophe.getResourceFromJid(jid), resource = Strophe.getResourceFromJid(jid),
presence_type = $(presence).attr('type'), presence_type = $presence.attr('type'),
show = $(presence).find('show'), show = $presence.find('show'),
status_message = $(presence).find('status'), status_message = $presence.find('status'),
item, model; item, model;
if (this.isSelf(bare_jid)) { if (this.isSelf(bare_jid)) {
...@@ -1515,11 +1517,11 @@ ...@@ -1515,11 +1517,11 @@
xmppchat.xmppstatus.set({'status': presence_type}); xmppchat.xmppstatus.set({'status': presence_type});
} }
return true; return true;
} else if (($(presence).find('x').attr('xmlns') || '').indexOf(Strophe.NS.MUC) === 0) { } else if (($presence.find('x').attr('xmlns') || '').indexOf(Strophe.NS.MUC) === 0) {
return true; // Ignore MUC return true; // Ignore MUC
} }
if ((status_message.length > 0) && (status_message.text() && (presence_type !== 'unavailable'))) { if ((status_message.length) && (status_message.text() && (presence_type !== 'unavailable'))) {
model = this.getItem(bare_jid); model = this.getItem(bare_jid);
model.set({'status': status_message.text()}); model.set({'status': status_message.text()});
} }
...@@ -1529,7 +1531,7 @@ ...@@ -1529,7 +1531,7 @@
} else if (presence_type === 'subscribe') { } else if (presence_type === 'subscribe') {
item = this.getItem(bare_jid); item = this.getItem(bare_jid);
// TODO see which auto_subscribe is seen as unresolved variable
if (xmppchat.auto_subscribe) { if (xmppchat.auto_subscribe) {
if ((!item) || (item.get('subscription') != 'to')) { if ((!item) || (item.get('subscription') != 'to')) {
if (xmppchat.connection.roster.findItem(bare_jid)) { if (xmppchat.connection.roster.findItem(bare_jid)) {
......
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