Performance fix. updates #151
_.pluck was being called inside the form loop.
This commit is contained in:
parent
235c3e15aa
commit
5839e38fc0
20
converse.js
20
converse.js
@ -3530,20 +3530,20 @@
|
|||||||
/* The localstorage cache containing roster contacts might contain
|
/* The localstorage cache containing roster contacts might contain
|
||||||
* some contacts that aren't actually in our roster anymore. We
|
* some contacts that aren't actually in our roster anymore. We
|
||||||
* therefore need to remove them now.
|
* therefore need to remove them now.
|
||||||
|
*
|
||||||
|
* TODO: The method is a performance bottleneck.
|
||||||
|
* Basically we need to chuck out strophe.roster and
|
||||||
|
* rewrite it with backbone.js and well integrated into
|
||||||
|
* converse.js. Then we won't need to have this method at all.
|
||||||
*/
|
*/
|
||||||
var id, i, contact;
|
_.each(_.difference(this.pluck('jid'), _.pluck(items, 'jid')), $.proxy(function (jid) {
|
||||||
for (i=0; i < this.models.length; ++i) {
|
var contact = this.get(jid);
|
||||||
id = this.models[i].get('id');
|
if (contact && !contact.get('requesting')) {
|
||||||
if (_.indexOf(_.pluck(items, 'jid'), id) === -1) {
|
contact.destroy();
|
||||||
contact = this.get(id);
|
|
||||||
if (contact && !contact.get('requesting')) {
|
|
||||||
contact.destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: see if we can only use 2nd item par
|
|
||||||
rosterHandler: function (items, item) {
|
rosterHandler: function (items, item) {
|
||||||
converse.emit('roster', items);
|
converse.emit('roster', items);
|
||||||
this.clearCache(items);
|
this.clearCache(items);
|
||||||
|
Loading…
Reference in New Issue
Block a user