mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-10 23:15:00 +08:00
fix(thread): handles new API with both folders and labels
This commit is contained in:
parent
ddc442d271
commit
69861049f0
1 changed files with 10 additions and 2 deletions
|
@ -200,6 +200,13 @@ class Thread extends ModelWithMetadata {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In the `clone` case, there are `categories` set, but no `folders` nor
|
||||||
|
* `labels`
|
||||||
|
*
|
||||||
|
* When loading data from the API, there are `folders` AND `labels` but
|
||||||
|
* no `categories` yet.
|
||||||
|
*/
|
||||||
fromJSON(json) {
|
fromJSON(json) {
|
||||||
super.fromJSON(json)
|
super.fromJSON(json)
|
||||||
|
|
||||||
|
@ -210,10 +217,11 @@ class Thread extends ModelWithMetadata {
|
||||||
|
|
||||||
if (json.labels) {
|
if (json.labels) {
|
||||||
this.categoriesType = 'labels'
|
this.categoriesType = 'labels'
|
||||||
this.categories = Thread.attributes.categories.fromJSON(json.labels)
|
if (!this.categories) this.categories = [];
|
||||||
|
this.categories = this.categories.concat(Thread.attributes.categories.fromJSON(json.labels))
|
||||||
}
|
}
|
||||||
|
|
||||||
['participants', 'categories'].forEach((attr) => {
|
['participants'].forEach((attr) => {
|
||||||
const value = this[attr]
|
const value = this[attr]
|
||||||
if (!(value && value instanceof Array)) {
|
if (!(value && value instanceof Array)) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue