mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-10 18:23:21 +08:00
27345e7719
Summary: fix message list nav buttons fix buttons Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://review.inboxapp.com/D1332
61 lines
1.4 KiB
CoffeeScript
61 lines
1.4 KiB
CoffeeScript
React = require "react/addons"
|
|
{ThreadStore} = require 'inbox-exports'
|
|
{RetinaImg} = require 'ui-components'
|
|
|
|
ThreadNavButtonMixin =
|
|
getInitialState: ->
|
|
@_getStateFromStores()
|
|
|
|
componentDidMount: ->
|
|
@_unsubscribe = ThreadStore.listen @_onThreadStoreChange
|
|
|
|
componentWillUnmount: ->
|
|
@_unsubscribe()
|
|
|
|
_onThreadStoreChange: ->
|
|
@setState @_getStateFromStores()
|
|
|
|
|
|
DownButton = React.createClass
|
|
mixins: [ThreadNavButtonMixin]
|
|
|
|
render: ->
|
|
<div className={@_classSet()} onClick={@_onClick}>
|
|
<RetinaImg name="toolbar-down-arrow.png"/>
|
|
</div>
|
|
|
|
_classSet: ->
|
|
React.addons.classSet
|
|
"message-toolbar-arrow": true
|
|
"down": true
|
|
"disabled": @state.disabled
|
|
|
|
_onClick: ->
|
|
return if @state.disabled
|
|
atom.commands.dispatch(document.body, 'application:next-item')
|
|
|
|
_getStateFromStores: ->
|
|
disabled: ThreadStore.isLastThread()
|
|
|
|
UpButton = React.createClass
|
|
mixins: [ThreadNavButtonMixin]
|
|
|
|
render: ->
|
|
<div className={@_classSet()} onClick={@_onClick}>
|
|
<RetinaImg name="toolbar-up-arrow.png"/>
|
|
</div>
|
|
|
|
_classSet: ->
|
|
React.addons.classSet
|
|
"message-toolbar-arrow": true
|
|
"up": true
|
|
"disabled": @state.disabled
|
|
|
|
_onClick: ->
|
|
return if @state.disabled
|
|
atom.commands.dispatch(document.body, 'application:previous-item')
|
|
|
|
_getStateFromStores: ->
|
|
disabled: ThreadStore.isFirstThread()
|
|
|
|
module.exports = {DownButton, UpButton}
|