From 21db84f13fe9c780ac33b2b8001211de1efa81fa Mon Sep 17 00:00:00 2001 From: Halla Moore Date: Wed, 4 Jan 2017 15:56:35 -0800 Subject: [PATCH] fix(Message): update fromJSON() Summary: - Handle `categories` if it exists, because clone() will call fromJSON() on the results of toJSON(), which populates `categories` instead of `folder` or `labels` - Remove the else-if for `folder` and `labels`, because both can co-exist. Also concatenate the results from these two, rathering than overwriting. Submodule commit is D3581, these two diffs together help make sure the inflated messages in N1 have the right categories. Test Plan: tested locally Reviewers: juan, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D3582 --- src/K2 | 2 +- src/flux/models/message.es6 | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/K2 b/src/K2 index 09f19d1ad..3336479d5 160000 --- a/src/K2 +++ b/src/K2 @@ -1 +1 @@ -Subproject commit 09f19d1adfec03c99fae0b4a1610b6c51e47f491 +Subproject commit 3336479d5dd1140dc18783ea1d0bb91081a5885a diff --git a/src/flux/models/message.es6 b/src/flux/models/message.es6 index 1c80c3fea..f0992967c 100644 --- a/src/flux/models/message.es6 +++ b/src/flux/models/message.es6 @@ -228,11 +228,18 @@ Message(date DESC) WHERE draft = 1`, this.draft = (json.object === 'draft') } - if (json.folder) { - this.categories = this.constructor.attributes.categories.fromJSON([json.folder]) - } else if (json.labels) { - this.categories = this.constructor.attributes.categories.fromJSON(json.labels) + let categories = [] + if (json.categories) { + categories = this.constructor.attributes.categories.fromJSON(json.categories) + } else { + if (json.folder) { + categories = categories.concat(this.constructor.attributes.categories.fromJSON([json.folder])) + } + if (json.labels) { + categories = categories.concat(this.constructor.attributes.categories.fromJSON(json.labels)) + } } + this.categories = categories for (const attr of ['to', 'from', 'cc', 'bcc', 'files', 'categories']) { const values = this[attr]