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 <br> 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
This commit is contained in:
Evan Morikawa 2015-07-13 10:12:52 -04:00
parent 07ef2e51a0
commit ca95d03c5d
2 changed files with 2 additions and 2 deletions

View file

@ -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 = (/^(<br[^>]*>)+$/gi).test(body)
onlyHasDoc = (/^<head><\/head><body><\/body>$/i).test(body)
onlyHasDoc = (/^<head><\/head><body><br><br><\/body>$/i).test(body)
bodyIsEmpty = body.length is 0 or onlyHasBr or onlyHasDoc
warnings = []

View file

@ -329,7 +329,7 @@ describe "populated composer", ->
useDraft.call @,
to: [u1]
subject: "Hello World"
body: "<head></head><body></body>"
body: "<head></head><body><br><br></body>"
makeComposer.call(@)
@composer._sendDraft()
expect(Actions.sendDraft).not.toHaveBeenCalled()