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)
This commit is contained in:
Steve Howell 2013-09-28 15:31:11 -04:00
parent ea7fda59d3
commit f67acb3157
1 changed files with 4 additions and 1 deletions

View File

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