Fix RosterHandler through proper closure.

This commit is contained in:
JC Brand 2013-03-05 18:35:06 +02:00
parent bd5269c232
commit 1966d5ab56

View File

@ -1524,14 +1524,11 @@
}, },
rosterHandler: function (items) { rosterHandler: function (items) {
var model, item, i, items_length = items.length, _.each(items, function (item, index, items) {
last_item = items[items_length - 1], var model = this.getItem(item.jid),
options = {}, vcard, img_src; options = {};
for (i=0; i<items_length; i+=1) {
item = items[i];
model = this.getItem(item.jid);
if (!model) { if (!model) {
if (item === last_item) { if (index === (items.length-1)) {
options.isLast = true; options.isLast = true;
} }
xmppchat.getVCard(item.jid, $.proxy(function (jid, fullname, img, img_type, url) { xmppchat.getVCard(item.jid, $.proxy(function (jid, fullname, img, img_type, url) {
@ -1545,7 +1542,8 @@
model.set({'subscription': item.subscription, 'ask': item.ask}); model.set({'subscription': item.subscription, 'ask': item.ask});
} }
} }
}
}, this);
}, },
presenceHandler: function (presence) { presenceHandler: function (presence) {