From f67acb31575cefb9bac91d591224542544abf665 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 28 Sep 2013 15:31:11 -0400 Subject: [PATCH] Filter duplicate messages more aggresively. This fixes a blueslip error where we were trying to add the same message into a MessageList twice. Muting complicates our duplicate detection, because empty() can return true even when we already are storing messages that just aren't shown (because of muting). The name empty() should probably be fixed in light of muting, but filtering with self.get() is not really a problem here. (imported from commit 83b0890471c9a0aa21996f3d0d3be4a238f23e65) --- static/js/message_list.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/static/js/message_list.js b/static/js/message_list.js index 71162be2c1..60a7fd0ffa 100644 --- a/static/js/message_list.js +++ b/static/js/message_list.js @@ -42,7 +42,10 @@ MessageList.prototype = { // If we're initially populating the list, save the messages in // bottom_messages regardless if (self.selected_id() === -1 && self.empty()) { - bottom_messages = _.filter(messages, predicate); + var narrow_messages = _.filter(messages, predicate); + bottom_messages = _.reject(narrow_messages, function (msg) { + return self.get(msg.id); + }); } else { _.each(messages, function (msg) { // Filter out duplicates that are already in self, and all messages