-
Notifications
You must be signed in to change notification settings - Fork 993
fix for the list not being updated after emails were deleted in search bar #2611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
0f948f0
cc12f26
d69c253
6fff514
690486b
c3dd903
483da65
ecf0aaa
846c678
9edca2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import { QuerySubscription } from './query-subscription'; | |
| import { DatabaseChangeRecord } from '../stores/database-change-record'; | ||
| import ModelQuery from './query'; | ||
| import { Model } from './model'; | ||
| import * as Actions from '../actions'; | ||
| let DatabaseStore = null; | ||
|
|
||
| /* | ||
|
|
@@ -105,6 +106,8 @@ class QuerySubscriptionPool { | |
| _setup() { | ||
| DatabaseStore = DatabaseStore || require('../stores/database-store').default; | ||
| DatabaseStore.listen(this._onChange); | ||
| Actions.queueTask.listen(this._onQueueTask); | ||
| Actions.queueTasks.listen(this._onQueueTasks); | ||
| } | ||
|
|
||
| _onChange = (record: DatabaseChangeRecord<Model>) => { | ||
|
|
@@ -113,6 +116,56 @@ class QuerySubscriptionPool { | |
| subscription.applyChangeRecord(record); | ||
| } | ||
| }; | ||
|
|
||
| _onQueueTask = (task) => { | ||
| const threadIds = this._threadIdsForRemovalTask(task); | ||
| if (threadIds && threadIds.length > 0) { | ||
| this._optimisticallyRemoveThreads(threadIds); | ||
| } | ||
| }; | ||
|
|
||
| _onQueueTasks = (tasks) => { | ||
| if (!tasks || !tasks.length) return; | ||
| const allIds: string[] = []; | ||
| for (const task of tasks) { | ||
| const ids = this._threadIdsForRemovalTask(task); | ||
| if (ids) { | ||
| allIds.push(...ids); | ||
| } | ||
| } | ||
| if (allIds.length > 0) { | ||
| this._optimisticallyRemoveThreads(allIds); | ||
| } | ||
| }; | ||
|
|
||
| _threadIdsForRemovalTask(task): string[] | null { | ||
| const ChangeFolderTask = require('../tasks/change-folder-task').ChangeFolderTask; | ||
| const ChangeLabelsTask = require('../tasks/change-labels-task').ChangeLabelsTask; | ||
|
|
||
| if (task instanceof ChangeFolderTask && task.threadIds && task.threadIds.length > 0) { | ||
|
indent-staging[bot] marked this conversation as resolved.
Outdated
|
||
| return task.threadIds; | ||
| } | ||
| if ( | ||
| task instanceof ChangeLabelsTask && | ||
| task.threadIds && | ||
| task.threadIds.length > 0 && | ||
| task.labelsToRemove && | ||
| task.labelsToRemove.length > 0 && | ||
| (!task.labelsToAdd || task.labelsToAdd.length === 0) | ||
| ) { | ||
| return task.threadIds; | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| _optimisticallyRemoveThreads(threadIds: string[]) { | ||
|
indent-staging[bot] marked this conversation as resolved.
Outdated
|
||
| for (const key of Object.keys(this._subscriptions)) { | ||
| const subscription = this._subscriptions[key]; | ||
| if (subscription._query && subscription._query.objectClass() === 'Thread') { | ||
| subscription.optimisticallyRemoveItemsById(threadIds); | ||
| } | ||
| } | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is super interesting - If the issue happens specifically with search, it'd be nice to move this logic down into the |
||
| } | ||
|
|
||
| const pool = new QuerySubscriptionPool(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.