diff --git a/js/views/conversation_search_view.js b/js/views/conversation_search_view.js index eb241cbb..fa88fc4b 100644 --- a/js/views/conversation_search_view.js +++ b/js/views/conversation_search_view.js @@ -125,7 +125,11 @@ if (this.showAllContacts) { this.typeahead.fetchAlphabetical().then(function() { if (this.typeahead.length > 0) { - this.typeahead_view.collection.reset(this.typeahead.models); + this.typeahead_view.collection.reset( + this.typeahead.filter(function(m) { + return m.isSearchable(); + }) + ); } else { this.showHints(); } diff --git a/test/views/conversation_search_view_test.js b/test/views/conversation_search_view_test.js index f48e6990..00f6d8b4 100644 --- a/test/views/conversation_search_view_test.js +++ b/test/views/conversation_search_view_test.js @@ -62,5 +62,44 @@ describe('ConversationSearchView', function() { }); }); }); + describe('Showing all contacts', function() { + var input = $(''); + var view = new Whisper.ConversationSearchView({ input: input }).render(); + view.showAllContacts = true; + var convo = new Whisper.ConversationCollection().add({ + id: 'a-left-group', + name: 'i left this group', + members: [], + type: 'group', + left: true + }); + before(function(done) { + convo.save().then(done); + }); + describe('with no messages', function() { + before(function(done) { + view.resetTypeahead(); + view.typeahead_view.collection.on('reset', function() { + done(); + }); + }); + it('should not surface left groups with no messages', function() { + assert.isUndefined(view.typeahead_view.collection.get(convo.id), 'got left group'); + }); + }); + describe('with messages', function() { + before(function(done) { + convo.save({lastMessage: 'asdf'}).then(function() { + view.typeahead_view.collection.on('reset', function() { + done(); + }); + view.resetTypeahead(); + }); + }); + it('should surface left groups with messages', function() { + assert.isDefined(view.typeahead_view.collection.get(convo.id), 'got left group'); + }); + }); + }); });