From 54bd4516ed42be572011e5307409fcaf1f8db689 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Wed, 1 May 2013 20:59:15 -0400 Subject: [PATCH] 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) --- zephyr/static/js/zephyr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 0ba372fc1a..72252482f9 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -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); }