From 24fac237cf4dd5e0d8cde5d29f25a6110b749d19 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Fri, 1 Dec 2017 14:43:37 -0800 Subject: [PATCH] Fix: sending draft with metadata when it has not yet been saved --- app/src/flux/stores/draft-store.es6 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/flux/stores/draft-store.es6 b/app/src/flux/stores/draft-store.es6 index 0854e3702..09470a087 100644 --- a/app/src/flux/stores/draft-store.es6 +++ b/app/src/flux/stores/draft-store.es6 @@ -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)) {