Fix: sending draft with metadata when it has not yet been saved

This commit is contained in:
Ben Gotow 2017-12-01 14:43:37 -08:00
parent 335373c69f
commit 24fac237cf

View file

@ -378,10 +378,15 @@ class DraftStore extends MailspringStore {
// completely saved and the user won't see old content briefly.
const session = await this.sessionForClientId(headerMessageId);
await session.ensureCorrectAccount();
let draft = session.draft();
await session.changes.commit();
await session.teardown();
// ensureCorrectAccount / commit may assign this draft a new ID. To move forward
// we need to have the final object with it's final ID.
let draft = await DatabaseStore.findBy(Message, { headerMessageId, draft: true }).include(
Message.attributes.body
);
draft = await DraftHelpers.applyExtensionTransforms(draft);
draft = await DraftHelpers.pruneRemovedInlineFiles(draft);
if (draft.replyToHeaderMessageId && DraftHelpers.shouldAppendQuotedText(draft)) {