Make contact sidebar use search API, not ThreadContact join table

This commit is contained in:
Ben Gotow 2017-06-26 23:55:20 -07:00
parent 6cbbd0a3dd
commit 1e5abf65dc
2 changed files with 11 additions and 12 deletions

View file

@ -88,10 +88,7 @@ class Thread extends ModelWithMetadata {
}),
participants: Attributes.Collection({
queryable: true,
modelKey: 'participants',
joinOnField: 'email',
joinQueryableBy: ['lastMessageReceivedTimestamp'],
itemClass: Contact,
}),

View file

@ -9,6 +9,7 @@ import Contact from '../models/contact';
import MessageStore from './message-store';
import AccountStore from './account-store';
import DatabaseStore from './database-store';
import SearchQueryParser from '../../services/search/search-query-parser';
// A store that handles the focuses collections of and individual contacts
class FocusedContactsStore extends NylasStore {
@ -95,8 +96,9 @@ class FocusedContactsStore extends NylasStore {
if (!email) {
return
}
const parsedQuery = SearchQueryParser.parse(`from:${email}`);
DatabaseStore.findAll(Thread)
.where(Thread.attributes.participants.contains(email))
.structuredSearch(parsedQuery)
.limit(100).background()
.then((threads = []) => {
if (currentContact.email !== email) {