From ca95d03c5d87a0e653452f80f2c91c7cc113ea19 Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Mon, 13 Jul 2015 10:12:52 -0400 Subject: [PATCH] fix(composer): warn when empty body Summary: Fixes T2276 Since the new `QuotedHTMLParser` uses full HTML parsing, when you ask it for the version of the document without the quoted nodes, it returns a full html document. Unfortunately I forgot about the 2
tags we manually generate when creating a reply to a message with quoted text. This is a pretty brittle solution, but considerably easier then checking if the contents really are "blank". We could check innerText, but would have to worry about img tags and other text-invisible-but-still-valid elements. Since we control the generation of the reply in the `DraftStore`, I think this is acceptable for now Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Maniphest Tasks: T2276 Differential Revision: https://phab.nylas.com/D1730 --- internal_packages/composer/lib/composer-view.cjsx | 2 +- internal_packages/composer/spec/composer-view-spec.cjsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal_packages/composer/lib/composer-view.cjsx b/internal_packages/composer/lib/composer-view.cjsx index feb74fae0..3248d92db 100644 --- a/internal_packages/composer/lib/composer-view.cjsx +++ b/internal_packages/composer/lib/composer-view.cjsx @@ -515,7 +515,7 @@ class ComposerView extends React.Component # We insert empty br tags before quoted text. # Our quoted text parser adds additional document elements onlyHasBr = (/^(]*>)+$/gi).test(body) - onlyHasDoc = (/^<\/head><\/body>$/i).test(body) + onlyHasDoc = (/^<\/head>

<\/body>$/i).test(body) bodyIsEmpty = body.length is 0 or onlyHasBr or onlyHasDoc warnings = [] diff --git a/internal_packages/composer/spec/composer-view-spec.cjsx b/internal_packages/composer/spec/composer-view-spec.cjsx index 25e920d1b..62af958f3 100644 --- a/internal_packages/composer/spec/composer-view-spec.cjsx +++ b/internal_packages/composer/spec/composer-view-spec.cjsx @@ -329,7 +329,7 @@ describe "populated composer", -> useDraft.call @, to: [u1] subject: "Hello World" - body: "" + body: "

" makeComposer.call(@) @composer._sendDraft() expect(Actions.sendDraft).not.toHaveBeenCalled()