Commit 95fdf98e authored by ichim-david's avatar ichim-david

Pass item to render method of RosterView instead of looping over each item on...

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
parent a875ba51
...@@ -1537,16 +1537,16 @@ ...@@ -1537,16 +1537,16 @@
this.model.remove(item.id); this.model.remove(item.id);
}, this); }, this);
} }
this.render(); this.render(item);
}, this); }, this);
this.model.on('change', function (item) { this.model.on('change', function (item) {
this.render(); this.render(item);
}, this); }, this);
this.model.on("remove", function (item) { this.model.on("remove", function (item) {
delete this.rosteritemviews[item.id]; delete this.rosteritemviews[item.id];
this.render(); this.render(item);
}, this); }, this);
this.$el.html(this.template()); this.$el.html(this.template());
...@@ -1556,20 +1556,19 @@ ...@@ -1556,20 +1556,19 @@
'<dt id="xmpp-contacts">My contacts</dt>' + '<dt id="xmpp-contacts">My contacts</dt>' +
'<dt id="pending-xmpp-contacts">Pending contacts</dt>'), '<dt id="pending-xmpp-contacts">Pending contacts</dt>'),
render: function () { render: function (item) {
var models = this.model.sort().models, if (!item) {
children = $(this.el).children(), return this;
$my_contacts = this.$el.find('#xmpp-contacts').hide(), }
$contact_requests = this.$el.find('#xmpp-contact-requests').hide(), var
$pending_contacts = this.$el.find('#pending-xmpp-contacts').hide(), $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; $count, num;
var user_id = Strophe.getNodeFromJid(item.id),
for (var i=0; i<models.length; i++) { view = this.rosteritemviews[item.id],
var model = models[i], ask = item.get('ask'),
user_id = Strophe.getNodeFromJid(model.id), subscription = item.get('subscription'),
view = this.rosteritemviews[model.id],
ask = model.get('ask'),
subscription = model.get('subscription'),
crit = {order:'asc'}; crit = {order:'asc'};
if (ask === 'subscribe') { if (ask === 'subscribe') {
...@@ -1586,11 +1585,10 @@ ...@@ -1586,11 +1585,10 @@
$my_contacts.after($my_contacts.siblings('dd.current-xmpp-contact.busy').tsort('a', crit)); $my_contacts.after($my_contacts.siblings('dd.current-xmpp-contact.busy').tsort('a', crit));
$my_contacts.after($my_contacts.siblings('dd.current-xmpp-contact.online').tsort('a', crit)); $my_contacts.after($my_contacts.siblings('dd.current-xmpp-contact.online').tsort('a', crit));
} }
}
// Hide the headings if there are no contacts under them // Hide the headings if there are no contacts under them
_.each([$my_contacts, $contact_requests, $pending_contacts], function (h) { _.each([$my_contacts, $contact_requests, $pending_contacts], function (h) {
if (h.nextUntil('dt').length > 0) { if (!h.nextUntil('dt').length) {
h.show(); h.hide();
} }
}); });
$count = $('#online-count'); $count = $('#online-count');
......
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