Omit left groups from search
Unless they contain messages. // FREEBIE
This commit is contained in:
parent
010297f4c5
commit
7e8ce5eb54
3 changed files with 14 additions and 3 deletions
|
@ -123,6 +123,10 @@
|
||||||
message.send(sendFunc(this.get('id'), body, attachments, now));
|
message.send(sendFunc(this.get('id'), body, attachments, now));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isSearchable: function() {
|
||||||
|
return !this.get('left') || !!this.get('lastMessage');
|
||||||
|
},
|
||||||
|
|
||||||
endSession: function() {
|
endSession: function() {
|
||||||
if (this.isPrivate()) {
|
if (this.isPrivate()) {
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
|
|
|
@ -394,7 +394,10 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchConversation: function(conversationId) {
|
fetchConversation: function(conversationId, limit) {
|
||||||
|
if (typeof limit !== 'number') {
|
||||||
|
limit = 100;
|
||||||
|
}
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
var upper;
|
var upper;
|
||||||
if (this.length === 0) {
|
if (this.length === 0) {
|
||||||
|
@ -404,7 +407,7 @@
|
||||||
// not our first rodeo, fetch older messages.
|
// not our first rodeo, fetch older messages.
|
||||||
upper = this.at(0).get('received_at');
|
upper = this.at(0).get('received_at');
|
||||||
}
|
}
|
||||||
var options = {remove: false, limit: 100};
|
var options = {remove: false, limit: limit};
|
||||||
options.index = {
|
options.index = {
|
||||||
// 'conversation' index on [conversationId, received_at]
|
// 'conversation' index on [conversationId, received_at]
|
||||||
name : 'conversation',
|
name : 'conversation',
|
||||||
|
|
|
@ -67,7 +67,11 @@
|
||||||
}
|
}
|
||||||
this.pending = this.pending.then(function() {
|
this.pending = this.pending.then(function() {
|
||||||
return this.typeahead.search(query).then(function() {
|
return this.typeahead.search(query).then(function() {
|
||||||
this.typeahead_view.collection.reset(this.typeahead.models);
|
this.typeahead_view.collection.reset(
|
||||||
|
this.typeahead.filter(function(m) {
|
||||||
|
return m.isSearchable();
|
||||||
|
})
|
||||||
|
);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
this.trigger('show');
|
this.trigger('show');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue