fix(sync) Make sure we can correctly archive/delete/mark as spam

Summary:
Previously, when moving to trash or spam, we were not correctly removing
the inbox category. This produced slightly different results because the
generated task was slightly different.

Also, in ChangeMailTask we were removing the locks on the models before
the tasks had actually succeeded-- these locks allowed us to ignore
deltas on those models while the task was in progress, so removing them
before it completed caused threads to flicker when performing actions

This depends on D3829 which also properly addresses
archiving/deleting/moving to spam threads that contain sent messages

Addresses T7757 and #2706

Test Plan: unit

Reviewers: evan, halla, spang

Reviewed By: evan, halla, spang

Differential Revision: https://phab.nylas.com/D3830
This commit is contained in:
Juan Tejada 2017-02-02 14:54:04 -08:00
parent d2580b691b
commit dd8b860be2
3 changed files with 5 additions and 6 deletions

View file

@ -237,11 +237,12 @@ export default class ChangeLabelsTask extends ChangeMailTask {
requestBodyForModel(model) {
const folder = model.labels.find(l => l.object === 'folder')
const labels = model.labels.filter(l => l.object === 'label').map(l => l.id)
const labels = model.labels.filter(l => l.object === 'label')
if (folder) {
return {
labels,
folder: folder.id,
labels: labels.map(l => l.id),
}
}
return {labels};

View file

@ -235,10 +235,6 @@ export default class ChangeMailTask extends Task {
if (!this._syncbackRequestIds) this._syncbackRequestIds = {}
this._syncbackRequestIds[model.id] = syncbackRequest.id
},
beforeProcessing: (body) => {
this._removeLock(model);
return body;
},
},
})
.run()

View file

@ -109,6 +109,7 @@ const TaskFactory = {
source,
threads,
categoriesToAdd: (accountId) => [CategoryStore.getSpamCategory(accountId)],
categoriesToRemove: (accountId) => [CategoryStore.getInboxCategory(accountId)],
})
},
@ -128,6 +129,7 @@ const TaskFactory = {
source,
threads,
categoriesToAdd: (accountId) => [CategoryStore.getTrashCategory(accountId)],
categoriesToRemove: (accountId) => [CategoryStore.getInboxCategory(accountId)],
})
},