mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-06 12:44:30 +08:00
[client-app] Reindex threads when they're updated
This commit is the same as 7d409f5. This commit was accidentally reverted in 95ec679, because I (juan) was being dumb. So I'm re-committing here. 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
This commit is contained in:
parent
c2a0df174f
commit
69aa71e575
1 changed files with 10 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue