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)
This commit is contained in:
Tim Abbott 2013-05-16 15:09:58 -04:00 committed by Leo Franchi
parent 7ebd214f89
commit 1df794efdc
1 changed files with 3 additions and 1 deletions

View File

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