mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-06 11:16:10 +08:00
fix(important): Hide important in message column of unified unless Gmail
This commit is contained in:
parent
ef7c98af2c
commit
ef5a8fc8e9
3 changed files with 39 additions and 26 deletions
|
@ -218,7 +218,7 @@ class MessageList extends React.Component
|
||||||
subject = "(No Subject)" if not subject or subject.length is 0
|
subject = "(No Subject)" if not subject or subject.length is 0
|
||||||
|
|
||||||
<div className="message-subject-wrap">
|
<div className="message-subject-wrap">
|
||||||
<MailImportantIcon thread={@state.currentThread} />
|
<MailImportantIcon thread={@state.currentThread}/>
|
||||||
<span className="message-subject">{subject}</span>
|
<span className="message-subject">{subject}</span>
|
||||||
{@_renderLabels()}
|
{@_renderLabels()}
|
||||||
{@_renderIcons()}
|
{@_renderIcons()}
|
||||||
|
|
|
@ -28,7 +28,10 @@ c1 = new ListTabular.Column
|
||||||
resolver: (thread) =>
|
resolver: (thread) =>
|
||||||
[
|
[
|
||||||
<ThreadListIcon key="thread-list-icon" thread={thread} />
|
<ThreadListIcon key="thread-list-icon" thread={thread} />
|
||||||
<MailImportantIcon key="mail-important-icon" thread={thread} />
|
<MailImportantIcon
|
||||||
|
key="mail-important-icon"
|
||||||
|
thread={thread}
|
||||||
|
showIfAvailableForAnyAccount={true} />
|
||||||
<InjectedComponentSet
|
<InjectedComponentSet
|
||||||
key="injected-component-set"
|
key="injected-component-set"
|
||||||
inline={true}
|
inline={true}
|
||||||
|
@ -125,7 +128,9 @@ cNarrow = new ListTabular.Column
|
||||||
{attachment}
|
{attachment}
|
||||||
<span className="timestamp">{timestamp(thread.lastMessageReceivedTimestamp)}</span>
|
<span className="timestamp">{timestamp(thread.lastMessageReceivedTimestamp)}</span>
|
||||||
</div>
|
</div>
|
||||||
<MailImportantIcon thread={thread} />
|
<MailImportantIcon
|
||||||
|
thread={thread}
|
||||||
|
showIfAvailableForAnyAccount={true} />
|
||||||
<div className="subject">{subject(thread.subject)}</div>
|
<div className="subject">{subject(thread.subject)}</div>
|
||||||
<div className="snippet">{thread.snippet}</div>
|
<div className="snippet">{thread.snippet}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,26 +15,32 @@ class MailImportantIcon extends React.Component
|
||||||
@displayName: 'MailImportantIcon'
|
@displayName: 'MailImportantIcon'
|
||||||
@propTypes:
|
@propTypes:
|
||||||
thread: React.PropTypes.object
|
thread: React.PropTypes.object
|
||||||
|
showIfAvailableForAnyAccount: React.PropTypes.bool
|
||||||
|
|
||||||
constructor: (@props) ->
|
constructor: (@props) ->
|
||||||
@state = @getState()
|
@state = @getState()
|
||||||
|
|
||||||
getState: =>
|
getState: (props = @props) =>
|
||||||
perspective = FocusedPerspectiveStore.current()
|
category = null
|
||||||
|
|
||||||
categoryId = null
|
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
for accountId in perspective.accountIds
|
if props.showIfAvailableForAnyAccount
|
||||||
account = AccountStore.accountForId(accountId)
|
perspective = FocusedPerspectiveStore.current()
|
||||||
accountImportantId = CategoryStore.getStandardCategory(account, 'important')?.id
|
for accountId in perspective.accountIds
|
||||||
if accountImportantId
|
account = AccountStore.accountForId(accountId)
|
||||||
visible = true
|
accountImportant = CategoryStore.getStandardCategory(account, 'important')
|
||||||
if accountId is @props.thread.accountId
|
if accountImportant
|
||||||
categoryId = accountImportantId
|
visible = true
|
||||||
break if visible and categoryId
|
if accountId is props.thread.accountId
|
||||||
|
category = accountImportant
|
||||||
|
break if visible and category
|
||||||
|
else
|
||||||
|
category = CategoryStore.getStandardCategory(props.thread.accountId, 'important')
|
||||||
|
visible = category?
|
||||||
|
|
||||||
{visible, categoryId}
|
isImportant = category and _.findWhere(@props.thread.categories, {id: category.id})?
|
||||||
|
|
||||||
|
{visible, category, isImportant}
|
||||||
|
|
||||||
componentDidMount: =>
|
componentDidMount: =>
|
||||||
@unsubscribe = FocusedPerspectiveStore.listen =>
|
@unsubscribe = FocusedPerspectiveStore.listen =>
|
||||||
|
@ -42,27 +48,27 @@ class MailImportantIcon extends React.Component
|
||||||
@subscription = NylasEnv.config.observe ShowImportantKey, =>
|
@subscription = NylasEnv.config.observe ShowImportantKey, =>
|
||||||
@setState(@getState())
|
@setState(@getState())
|
||||||
|
|
||||||
|
componentWillReceiveProps: (nextProps) =>
|
||||||
|
@setState(@getState(nextProps))
|
||||||
|
|
||||||
componentWillUnmount: =>
|
componentWillUnmount: =>
|
||||||
@unsubscribe?()
|
@unsubscribe?()
|
||||||
@subscription?.dispose()
|
@subscription?.dispose()
|
||||||
|
|
||||||
shouldComponentUpdate: (nextProps, nextState) =>
|
shouldComponentUpdate: (nextProps, nextState) =>
|
||||||
return false if nextProps.thread is @props.thread and @state.visible is nextState.visible and @state.categoryId is nextState.categoryId
|
not _.isEqual(nextState, @state)
|
||||||
true
|
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
return false unless @state.visible
|
return false unless @state.visible
|
||||||
|
|
||||||
isImportant = @state.categoryId and _.findWhere(@props.thread.categories, {id: @state.categoryId})?
|
|
||||||
|
|
||||||
classes = classNames
|
classes = classNames
|
||||||
'mail-important-icon': true
|
'mail-important-icon': true
|
||||||
'enabled': @state.categoryId
|
'enabled': @state.category?
|
||||||
'active': isImportant
|
'active': @state.isImportant
|
||||||
|
|
||||||
if not @state.categoryId
|
if not @state.category
|
||||||
title = "No important folder / label"
|
title = "No important folder / label"
|
||||||
else if isImportant
|
else if @state.isImportant
|
||||||
title = "Mark as unimportant"
|
title = "Mark as unimportant"
|
||||||
else
|
else
|
||||||
title = "Mark as important"
|
title = "Mark as important"
|
||||||
|
@ -72,8 +78,10 @@ class MailImportantIcon extends React.Component
|
||||||
onClick={@_onToggleImportant}></div>
|
onClick={@_onToggleImportant}></div>
|
||||||
|
|
||||||
_onToggleImportant: (event) =>
|
_onToggleImportant: (event) =>
|
||||||
if @state.categoryId
|
{category} = @state
|
||||||
isImportant = _.findWhere(@props.thread.categories, {id: @state.categoryId})?
|
|
||||||
|
if category
|
||||||
|
isImportant = _.findWhere(@props.thread.categories, {id: category.id})?
|
||||||
threads = [@props.thread]
|
threads = [@props.thread]
|
||||||
|
|
||||||
if !isImportant
|
if !isImportant
|
||||||
|
|
Loading…
Add table
Reference in a new issue