Only update recent subjects after all messages in a batch have been processed

We were previously doing this on every message.  Because
update_recent_subjects is linear in the number of streams in the
sidebar, this became very slow when we enabled the streams sidebar
for the MIT realm.

(imported from commit 95cd71d83bbcc08cc6c5c79ca567b5d6b9b17173)
This commit is contained in:
Zev Benjamin 2013-05-01 20:59:15 -04:00
parent a640da16df
commit 54bd4516ed
1 changed files with 3 additions and 3 deletions

View File

@ -478,8 +478,6 @@ function case_insensitive_find(term, array) {
}).length !== 0;
}
var update_recent_subjects = $.debounce(100, ui.update_recent_subjects);
function process_message_for_recent_subjects(message) {
var current_timestamp = 0;
var max_subjects = 5;
@ -508,7 +506,6 @@ function process_message_for_recent_subjects(message) {
recents = recents.slice(0, max_subjects);
recent_subjects[message.stream] = recents;
update_recent_subjects();
}
function add_message_metadata(message, dummy) {
@ -818,6 +815,7 @@ function get_updates(options) {
process_visible_unread_messages();
notifications.received_messages(messages);
compose.update_faded_messages();
ui.update_recent_subjects();
}
if (new_pointer !== undefined
@ -897,6 +895,8 @@ function load_old_messages(opts) {
add_messages(messages, opts.msg_list);
}
ui.update_recent_subjects();
if (opts.cont !== undefined) {
opts.cont(messages);
}