2015-09-16 07:49:16 +08:00
|
|
|
React = require 'react'
|
|
|
|
{Actions, FocusedContentStore, ChangeUnreadTask} = require 'nylas-exports'
|
2015-12-01 10:19:47 +08:00
|
|
|
{RetinaImg, KeyCommandsRegion} = require 'nylas-component-kit'
|
2015-09-16 07:49:16 +08:00
|
|
|
|
|
|
|
class ThreadToggleUnreadButton extends React.Component
|
|
|
|
@displayName: "ThreadToggleUnreadButton"
|
|
|
|
@containerRequired: false
|
|
|
|
|
|
|
|
render: =>
|
|
|
|
fragment = if @props.thread?.unread then "read" else "unread"
|
|
|
|
|
2015-12-01 10:19:47 +08:00
|
|
|
<KeyCommandsRegion globalHandlers={@_globalHandlers()} >
|
|
|
|
<button className="btn btn-toolbar"
|
|
|
|
style={order: -105}
|
|
|
|
title="Mark as #{fragment}"
|
|
|
|
onClick={@_onClick}>
|
|
|
|
<RetinaImg name="toolbar-markas#{fragment}.png"
|
|
|
|
mode={RetinaImg.Mode.ContentIsMask} />
|
|
|
|
</button>
|
|
|
|
</KeyCommandsRegion>
|
|
|
|
|
|
|
|
_globalHandlers: =>
|
|
|
|
'application:mark-as-unread': (e) => @_setUnread(e, true)
|
|
|
|
'application:mark-as-read': (e) => @_setUnread(e, false)
|
2015-09-16 07:49:16 +08:00
|
|
|
|
|
|
|
_onClick: (e) =>
|
2015-12-01 10:19:47 +08:00
|
|
|
@_setUnread(e, !@props.thread.unread)
|
|
|
|
|
|
|
|
_setUnread: (e, unread)=>
|
2015-09-16 07:49:16 +08:00
|
|
|
task = new ChangeUnreadTask
|
|
|
|
thread: @props.thread
|
2015-12-01 10:19:47 +08:00
|
|
|
unread: unread
|
2015-10-22 01:38:00 +08:00
|
|
|
Actions.queueTask(task)
|
2015-09-16 07:49:16 +08:00
|
|
|
Actions.popSheet()
|
2015-10-22 01:38:00 +08:00
|
|
|
e.stopPropagation()
|
2015-09-16 07:49:16 +08:00
|
|
|
|
|
|
|
module.exports = ThreadToggleUnreadButton
|