[isomorphic-core] don't try and inflate delete deltas

Summary:
If we inflate delete deltas, the object we're trying to find won't exist
anymore (we just deleted it!). This is likely causing the `While inflating
${sourceName} transactions, we couldn't find models for some ${modelName}
IDs` error.

Fixes T7436

Test Plan: manual

Reviewers: spang, juan, halla

Reviewed By: halla

Maniphest Tasks: T7436

Differential Revision: https://phab.nylas.com/D3621
This commit is contained in:
Evan Morikawa 2017-01-10 10:21:14 -08:00
parent ac08163c51
commit b03c0c9bc2

View file

@ -10,7 +10,10 @@ const stream = require('stream');
* the inflated model they reference.
*/
function inflateTransactions(db, accountId, transactions = [], sourceName) {
const transactionJSONs = transactions.map((t) => (t.toJSON ? t.toJSON() : t))
const transactionJSONs = transactions
.filter((t) => t.event !== 'delete')
.map((t) => (t.toJSON ? t.toJSON() : t))
transactionJSONs.forEach((t) => {
t.cursor = t.id;
t.accountId = accountId;