Don't show left groups in list of all contacts
// FREEBIE
This commit is contained in:
parent
ef9559d844
commit
cc0b8e835a
2 changed files with 44 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -62,5 +62,44 @@ describe('ConversationSearchView', function() {
|
|||
});
|
||||
});
|
||||
});
|
||||
describe('Showing all contacts', function() {
|
||||
var input = $('<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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue