mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 12:21:58 +00:00
Set initial user presences in O(n), not O(n²) time
Previous code iteratively called set_user_status() once for each user; which in turn was rerendering the user sidebar, also once for each user. I changed the API a bit by replacing activity.set_user_status() with activity.set_user_statuses(), plural, that takes an object and updates all the user statuses in one go before rendering. (imported from commit 1111c9029264f892f25e76d2e5e5ff996dcbc7ca)
This commit is contained in:
@@ -72,10 +72,8 @@ $(function () {
|
||||
"full_name": "Humbug Feedback Bot"});
|
||||
}
|
||||
|
||||
$.each(page_params.initial_presences, function (email, presence) {
|
||||
activity.set_user_status(email, presence, page_params.initial_servertime);
|
||||
});
|
||||
|
||||
activity.set_user_statuses(page_params.initial_presences,
|
||||
page_params.initial_servertime);
|
||||
});
|
||||
|
||||
function within_viewport(row_offset, row_height) {
|
||||
@@ -823,7 +821,9 @@ function get_updates_success(data) {
|
||||
}
|
||||
break;
|
||||
case 'presence':
|
||||
activity.set_user_status(event.email, event.presence, event.server_timestamp);
|
||||
var users = {};
|
||||
users[event.email] = event.presence;
|
||||
activity.set_user_statuses(users, event.server_timestamp);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user