feat(composer): show quoted text when forwarding messages

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://review.inboxapp.com/D1291
This commit is contained in:
Evan Morikawa 2015-03-13 16:17:18 -04:00
parent c301dcfbb1
commit 02439f3a28
4 changed files with 22 additions and 11 deletions

View file

@ -32,6 +32,7 @@ ComposerView = React.createClass
bcc: []
body: ""
subject: ""
showQuotedText: false
isSending: DraftStore.sendingState(@props.localId)
state
@ -204,6 +205,7 @@ ComposerView = React.createClass
html={@state.body}
onChange={@_onChangeBody}
style={@_precalcComposerCss}
initialEditQuotedText={@state.showQuotedText}
initialSelectionSnapshot={@_recoveredSelection}
tabIndex="109" />
</div>
@ -220,7 +222,8 @@ ComposerView = React.createClass
isForwardedMessage: ->
draft = @_proxy.draft()
draft.subject[0...3].toLowerCase() is "fwd"
return false if not draft? or not draft.subject?
Utils.isForwardedMessage(draft.body, draft.subject)
_footerComponents: ->
(@state.FooterComponents ? []).map (Component) =>
@ -253,6 +256,7 @@ ComposerView = React.createClass
showcc: not _.isEmpty(draft.cc)
showbcc: not _.isEmpty(draft.bcc)
showsubject: @_shouldShowSubject()
showQuotedText: @isForwardedMessage()
populated: true
@setState(state)

View file

@ -18,7 +18,7 @@ ContenteditableComponent = React.createClass
toolbarLeft: 0
editAreaWidth: 9999 # This will get set on first selection
toolbarVisible: false
editQuotedText: false
editQuotedText: @props.initialEditQuotedText ? false
componentDidMount: ->
@_setupSelectionListeners()
@ -29,6 +29,7 @@ ContenteditableComponent = React.createClass
@_teardownLinkHoverListeners()
componentWillReceiveProps: (nextProps) ->
@setState editQuotedText: nextProps.initialEditQuotedText
if nextProps.initialSelectionSnapshot?
@_setSelectionSnapshot(nextProps.initialSelectionSnapshot)

View file

@ -24,7 +24,7 @@ MessageItem = React.createClass
# Holds the downloadData (if any) for all of our files. It's a hash
# keyed by a fileId. The value is the downloadData.
downloads: FileDownloadStore.downloadsForFileIds(@props.message.fileIds())
showQuotedText: @_messageIsEmptyForward()
showQuotedText: @_isForwardedMessage()
detailedHeaders: false
componentDidMount: ->
@ -171,14 +171,8 @@ MessageItem = React.createClass
attachments.map (file) =>
<AttachmentComponent file={file} key={file.id} download={@state.downloads[file.id]}/>
_messageIsEmptyForward: ->
# Returns true if the message contains "Forwarded" or "Fwd" in the first 250 characters.
# A strong indicator that the quoted text should be shown. Needs to be limited to first 250
# to prevent replies to forwarded messages from also being expanded.
body = @props.message.body.toLowerCase()
indexForwarded = body.indexOf('forwarded')
indexFwd = body.indexOf('fwd')
(indexForwarded >= 0 and indexForwarded < 250) or (indexFwd >= 0 and indexFwd < 250)
_isForwardedMessage: ->
Utils.isForwardedMessage(@props.message.body, @props.message.subject)
_onDownloadStoreChange: ->
@setState

View file

@ -154,6 +154,18 @@ Utils =
# Return remaining compacted email body
lines.join('\n')
# Returns true if the message contains "Forwarded" or "Fwd" in the first
# 250 characters. A strong indicator that the quoted text should be
# shown. Needs to be limited to first 250 to prevent replies to
# forwarded messages from also being expanded.
isForwardedMessage: (body="", subject="") ->
indexForwarded = body.indexOf('forwarded')
indexFwd = body.indexOf('fwd')
return (indexForwarded >= 0 and indexForwarded < 250) or
(indexFwd >= 0 and indexFwd < 250) or
(subject[0...3].toLowerCase() is "fwd")
# Checks to see if a particular node is visible and any of its parents
# are visible.
#