From 1df794efdcc15940928c141920bd63efdd3a7ece Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 16 May 2013 15:09:58 -0400 Subject: [PATCH] Don't use all_msg_list to memoize add_message_metadata. The problem is that if you load a browser window in a stream narrow, add_message_metadata will be called for the messages in the narrowed view before it is called for the messages going into the main view (thus inserting them into all_msg_list), resulting in duplicate copies of messages. This would be mostly OK except that we call process_message_for_recent_subjects inside add_message_metadata, and that function assumes it is only called once on each message (otherwise it'll double-count the message). (imported from commit a3e7f85874100cd93a6d07684605da04d9cc80c7) --- zephyr/static/js/zephyr.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index ee6f8d868d..8438511f55 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -572,8 +572,9 @@ function process_message_for_recent_subjects(message) { recent_subjects[message.stream] = recents; } +var msg_metadata_cache = {}; function add_message_metadata(message, dummy) { - var cached_msg = all_msg_list.get(message.id); + var cached_msg = msg_metadata_cache[message.id]; if (cached_msg !== undefined) { // Copy the match subject and content over if they exist on // the new message @@ -639,6 +640,7 @@ function add_message_metadata(message, dummy) { } }); + msg_metadata_cache[message.id] = message; return message; }