Skip to content

Commit

Permalink
[client-app] Reindex threads when they're updated
Browse files Browse the repository at this point in the history
Summary:
We weren't doing that, so we would have accurate search index info for
threads when they were, e.g., moved to another folder.

Test Plan: Run locally

Reviewers: spang, evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D4260
  • Loading branch information
Mark Hahnenberg committed Mar 24, 2017
1 parent ae1c667 commit 11aa686
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,21 @@ class ThreadSearchIndexStore {
if (change.objectClass !== Thread.name) {
return;
}
_.defer(() => {
_.defer(async () => {
const {objects, type} = change
const threads = objects;

let promises = []
if (type === 'persist') {
const alreadyIndexedThreads = threads.filter(t => t.isSearchIndexed)
if (alreadyIndexedThreads.length > 0) {
alreadyIndexedThreads.forEach(thread => {
// Mark already indexed threads as unindexed so that we re-index them
// with updates
thread.isSearchIndexed = false
})
await DatabaseStore.inTransaction(t => t.persistModels(alreadyIndexedThreads))
}
this.indexer.notifyHasIndexingToDo();
} else if (type === 'unpersist') {
promises = threads.map(thread => this.unindexThread(thread,
Expand Down

0 comments on commit 11aa686

Please sign in to comment.