From f4ff6370b9746613a4dabda2b24059dd8b236190 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sat, 25 Oct 2014 09:57:05 +0200 Subject: [PATCH] Performance fix. Debounce the update method on the roster. --- converse.js | 4 ++-- spec/profiling.js | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/converse.js b/converse.js index 07593cde2..e0865331d 100644 --- a/converse.js +++ b/converse.js @@ -3851,14 +3851,14 @@ this.model.on("reset", this.reset, this); }, - update: function () { + update: _.debounce(function () { var $count = $('#online-count'); $count.text('('+converse.roster.getNumOnlineContacts()+')'); if (!$count.is(':visible')) { $count.show(); } return this.showHideFilter(); - }, + }, 300), render: function () { this.$el.html(converse.templates.roster({ diff --git a/spec/profiling.js b/spec/profiling.js index 78c167e3b..f7f742bdf 100644 --- a/spec/profiling.js +++ b/spec/profiling.js @@ -50,7 +50,5 @@ it("contacts in a very large roster change their statuses", $.proxy(function() { }, converse)); - }); - }));