Throttle user list updates to 5s intervals.

(imported from commit 908806d1ac00f14802f2a01a40d0abb66778a441)
This commit is contained in:
Steve Howell 2013-12-17 11:34:46 -05:00
parent 8dcf7d4cc3
commit f174038100
1 changed files with 9 additions and 1 deletions

View File

@ -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