From 1e5abf65dcef2a70376ade7511e65f7d5f2fb0dc Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Mon, 26 Jun 2017 23:55:20 -0700 Subject: [PATCH] Make contact sidebar use search API, not ThreadContact join table --- .../client-app/src/flux/models/thread.es6 | 3 --- .../flux/stores/focused-contacts-store.es6 | 20 ++++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/client-app/src/flux/models/thread.es6 b/packages/client-app/src/flux/models/thread.es6 index 41f7207a2..ebbc074e8 100644 --- a/packages/client-app/src/flux/models/thread.es6 +++ b/packages/client-app/src/flux/models/thread.es6 @@ -88,10 +88,7 @@ class Thread extends ModelWithMetadata { }), participants: Attributes.Collection({ - queryable: true, modelKey: 'participants', - joinOnField: 'email', - joinQueryableBy: ['lastMessageReceivedTimestamp'], itemClass: Contact, }), diff --git a/packages/client-app/src/flux/stores/focused-contacts-store.es6 b/packages/client-app/src/flux/stores/focused-contacts-store.es6 index f1a00552c..417b356e0 100644 --- a/packages/client-app/src/flux/stores/focused-contacts-store.es6 +++ b/packages/client-app/src/flux/stores/focused-contacts-store.es6 @@ -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,16 +96,17 @@ class FocusedContactsStore extends NylasStore { if (!email) { return } + const parsedQuery = SearchQueryParser.parse(`from:${email}`); DatabaseStore.findAll(Thread) - .where(Thread.attributes.participants.contains(email)) - .limit(100).background() - .then((threads = []) => { - if (currentContact.email !== email) { - return - } - this._currentParticipantThreads = threads; - this.trigger(); - }); + .structuredSearch(parsedQuery) + .limit(100).background() + .then((threads = []) => { + if (currentContact.email !== email) { + return + } + this._currentParticipantThreads = threads; + this.trigger(); + }); } // We score everyone to determine who's the most relevant to display in