From f174038100dcf9f767632d077ac47fc2f459505f Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 17 Dec 2013 11:34:46 -0500 Subject: [PATCH] Throttle user list updates to 5s intervals. (imported from commit 908806d1ac00f14802f2a01a40d0abb66778a441) --- static/js/activity.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/static/js/activity.js b/static/js/activity.js index 6d56e4a8a8..36c1785f2e 100644 --- a/static/js/activity.js +++ b/static/js/activity.js @@ -150,7 +150,7 @@ function focus_lost() { exports.has_focus = false; } -function update_users() { +function actually_update_users() { if (page_params.domain === 'mit.edu') { return; // MIT realm doesn't have a presence list } @@ -196,6 +196,14 @@ function update_users() { compose_fade.update_faded_users(); } +// The function actually_update_users() can be pretty expensive for realms with lots +// of users. Not only is there more work to do in terms of rendering the user list, but +// we also get more updates. Large realms have reported lags while typing in the compose +// box, and there's strong evidence that this is caused by user list updates. This isn't a +// perfect solution, but it should remove some pain, and there's no real harm in waiting five +// seconds to update user activity. +var update_users = _.throttle(actually_update_users, 5000); + exports.update_huddles = function () { if (page_params.domain === 'mit.edu') { return; // MIT realm doesn't have a presence list