From ef5a8fc8e904e08d06a42dc9f20edaaf5d1deef6 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 28 Jan 2016 16:44:44 -0800 Subject: [PATCH] fix(important): Hide important in message column of unified unless Gmail --- .../message-list/lib/message-list.cjsx | 2 +- .../thread-list/lib/thread-list-columns.cjsx | 9 +++- src/components/mail-important-icon.cjsx | 54 +++++++++++-------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/internal_packages/message-list/lib/message-list.cjsx b/internal_packages/message-list/lib/message-list.cjsx index 3f2e50635..d6f102a71 100755 --- a/internal_packages/message-list/lib/message-list.cjsx +++ b/internal_packages/message-list/lib/message-list.cjsx @@ -218,7 +218,7 @@ class MessageList extends React.Component subject = "(No Subject)" if not subject or subject.length is 0
- + {subject} {@_renderLabels()} {@_renderIcons()} diff --git a/internal_packages/thread-list/lib/thread-list-columns.cjsx b/internal_packages/thread-list/lib/thread-list-columns.cjsx index aa4a4a3a2..5ed95461b 100644 --- a/internal_packages/thread-list/lib/thread-list-columns.cjsx +++ b/internal_packages/thread-list/lib/thread-list-columns.cjsx @@ -28,7 +28,10 @@ c1 = new ListTabular.Column resolver: (thread) => [ - + {timestamp(thread.lastMessageReceivedTimestamp)}
- +
{subject(thread.subject)}
{thread.snippet}
diff --git a/src/components/mail-important-icon.cjsx b/src/components/mail-important-icon.cjsx index 1865ab1f8..b7e51b423 100644 --- a/src/components/mail-important-icon.cjsx +++ b/src/components/mail-important-icon.cjsx @@ -15,26 +15,32 @@ class MailImportantIcon extends React.Component @displayName: 'MailImportantIcon' @propTypes: thread: React.PropTypes.object + showIfAvailableForAnyAccount: React.PropTypes.bool constructor: (@props) -> @state = @getState() - getState: => - perspective = FocusedPerspectiveStore.current() - - categoryId = null + getState: (props = @props) => + category = null visible = false - for accountId in perspective.accountIds - account = AccountStore.accountForId(accountId) - accountImportantId = CategoryStore.getStandardCategory(account, 'important')?.id - if accountImportantId - visible = true - if accountId is @props.thread.accountId - categoryId = accountImportantId - break if visible and categoryId + if props.showIfAvailableForAnyAccount + perspective = FocusedPerspectiveStore.current() + for accountId in perspective.accountIds + account = AccountStore.accountForId(accountId) + accountImportant = CategoryStore.getStandardCategory(account, 'important') + if accountImportant + visible = true + 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: => @unsubscribe = FocusedPerspectiveStore.listen => @@ -42,27 +48,27 @@ class MailImportantIcon extends React.Component @subscription = NylasEnv.config.observe ShowImportantKey, => @setState(@getState()) + componentWillReceiveProps: (nextProps) => + @setState(@getState(nextProps)) + componentWillUnmount: => @unsubscribe?() @subscription?.dispose() shouldComponentUpdate: (nextProps, nextState) => - return false if nextProps.thread is @props.thread and @state.visible is nextState.visible and @state.categoryId is nextState.categoryId - true + not _.isEqual(nextState, @state) render: => return false unless @state.visible - isImportant = @state.categoryId and _.findWhere(@props.thread.categories, {id: @state.categoryId})? - classes = classNames 'mail-important-icon': true - 'enabled': @state.categoryId - 'active': isImportant + 'enabled': @state.category? + 'active': @state.isImportant - if not @state.categoryId + if not @state.category title = "No important folder / label" - else if isImportant + else if @state.isImportant title = "Mark as unimportant" else title = "Mark as important" @@ -72,8 +78,10 @@ class MailImportantIcon extends React.Component onClick={@_onToggleImportant}> _onToggleImportant: (event) => - if @state.categoryId - isImportant = _.findWhere(@props.thread.categories, {id: @state.categoryId})? + {category} = @state + + if category + isImportant = _.findWhere(@props.thread.categories, {id: category.id})? threads = [@props.thread] if !isImportant