From 95fdf98ea695946321be0c1f1db5cf5e7f3bee43 Mon Sep 17 00:00:00 2001 From: ichim-david Date: Wed, 20 Feb 2013 15:36:55 +0200 Subject: [PATCH] Pass item to render method of RosterView instead of looping over each item on every render call, Inverted visibility logic for contact titles in order to avoid multiple show and hide --- converse.js | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/converse.js b/converse.js index b68c09cd6..39b7d818f 100644 --- a/converse.js +++ b/converse.js @@ -1537,16 +1537,16 @@ this.model.remove(item.id); }, this); } - this.render(); + this.render(item); }, this); this.model.on('change', function (item) { - this.render(); + this.render(item); }, this); this.model.on("remove", function (item) { delete this.rosteritemviews[item.id]; - this.render(); + this.render(item); }, this); this.$el.html(this.template()); @@ -1556,20 +1556,19 @@ '
My contacts
' + '
Pending contacts
'), - render: function () { - var models = this.model.sort().models, - children = $(this.el).children(), - $my_contacts = this.$el.find('#xmpp-contacts').hide(), - $contact_requests = this.$el.find('#xmpp-contact-requests').hide(), - $pending_contacts = this.$el.find('#pending-xmpp-contacts').hide(), + render: function (item) { + if (!item) { + return this; + } + var + $my_contacts = this.$el.find('#xmpp-contacts').show(), + $contact_requests = this.$el.find('#xmpp-contact-requests').show(), + $pending_contacts = this.$el.find('#pending-xmpp-contacts').show(), $count, num; - - for (var i=0; i 0) { - h.show(); + if (!h.nextUntil('dt').length) { + h.hide(); } }); $count = $('#online-count');