mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-06 12:44:30 +08:00
[local-sync] Correctly check presence of messages when updating thread
Summary: updateMessagesFromThread requires `messages` to be an array only when recompute is falsy Test Plan: manual Reviewers: halla Reviewed By: halla Differential Revision: https://phab.nylas.com/D3797
This commit is contained in:
parent
651a199cb6
commit
4480fd89a2
1 changed files with 6 additions and 3 deletions
|
@ -99,9 +99,6 @@ module.exports = (sequelize, Sequelize) => {
|
||||||
},
|
},
|
||||||
|
|
||||||
async updateFromMessages({db, messages, recompute, transaction} = {}) {
|
async updateFromMessages({db, messages, recompute, transaction} = {}) {
|
||||||
if (!(messages instanceof Array)) {
|
|
||||||
throw new Error('Thread.updateFromMessages() expected an array of messages')
|
|
||||||
}
|
|
||||||
if (!(this.folders instanceof Array) || !(this.labels instanceof Array)) {
|
if (!(this.folders instanceof Array) || !(this.labels instanceof Array)) {
|
||||||
throw new Error('Thread.updateFromMessages() expected .folders and .labels to be inflated arrays')
|
throw new Error('Thread.updateFromMessages() expected .folders and .labels to be inflated arrays')
|
||||||
}
|
}
|
||||||
|
@ -131,6 +128,12 @@ module.exports = (sequelize, Sequelize) => {
|
||||||
this.firstMessageDate = null;
|
this.firstMessageDate = null;
|
||||||
this.lastMessageSentDate = null;
|
this.lastMessageSentDate = null;
|
||||||
this.lastMessageReceivedDate = null;
|
this.lastMessageReceivedDate = null;
|
||||||
|
} else {
|
||||||
|
// If we're not recomputing from all of the thread's messages, we need
|
||||||
|
// to know which messages to update from
|
||||||
|
if (!(_messages instanceof Array)) {
|
||||||
|
throw new Error('Thread.updateFromMessages() expected an array of messages')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const folderIds = new Set(this.folders.map(f => f.id));
|
const folderIds = new Set(this.folders.map(f => f.id));
|
||||||
|
|
Loading…
Add table
Reference in a new issue