mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
f1cec289af
Summary: Fixes T1162: Search no longer lowercases Fixes T1212: Selection anchor nodes are restored properly Fixes T1254: Make sessionForLocalId return a promise Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Subscribers: mg Maniphest Tasks: T1263, T1212, T1162, T1254 Differential Revision: https://review.inboxapp.com/D1512
47 lines
1.2 KiB
CoffeeScript
47 lines
1.2 KiB
CoffeeScript
_ = require 'underscore-plus'
|
|
React = require 'react'
|
|
{Actions, Message, DraftStore} = require 'inbox-exports'
|
|
|
|
class TemplateStatusBar extends React.Component
|
|
@displayName: 'TemplateStatusBar'
|
|
|
|
@containerStyles:
|
|
textAlign:'center'
|
|
width:530
|
|
margin:'auto'
|
|
|
|
@propTypes:
|
|
draftLocalId: React.PropTypes.string
|
|
|
|
constructor: (@props) ->
|
|
@state = draft: null
|
|
|
|
componentDidMount: =>
|
|
DraftStore.sessionForLocalId(@props.draftLocalId).then (_proxy) =>
|
|
return if @_unmounted
|
|
return unless _proxy.draftLocalId is @props.draftLocalId
|
|
@_proxy = _proxy
|
|
@unsubscribe = @_proxy.listen(@_onDraftChange, @)
|
|
@_onDraftChange()
|
|
|
|
componentWillUnmount: =>
|
|
@_unmounted = true
|
|
@unsubscribe() if @unsubscribe
|
|
|
|
render: =>
|
|
if @_draftUsesTemplate()
|
|
<div className="template-status-bar">
|
|
Press "tab" to quickly fill in the blanks - highlighting will not be visible to recipients.
|
|
</div>
|
|
else
|
|
<div></div>
|
|
|
|
_onDraftChange: =>
|
|
@setState(draft: @_proxy.draft())
|
|
|
|
_draftUsesTemplate: =>
|
|
return unless @state.draft
|
|
@state.draft.body.search(/<code[^>]*class="var[^>]*>/i) > 0
|
|
|
|
|
|
module.exports = TemplateStatusBar
|