fix(shortcuts): Fix shortcut handlers for marking as read/unread

- Marking as read/unread did not work when selecting multiple threads
This commit is contained in:
Juan Tejada 2015-12-14 10:32:45 -08:00
parent b9253ebbfd
commit 7275336665
2 changed files with 30 additions and 22 deletions

View file

@ -8,28 +8,18 @@ class ThreadToggleUnreadButton extends React.Component
render: =>
fragment = if @props.thread?.unread then "read" else "unread"
<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)
<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>
_onClick: (e) =>
@_setUnread(e, !@props.thread.unread)
_setUnread: (e, unread)=>
task = new ChangeUnreadTask
thread: @props.thread
unread: unread
unread: !@props.thread.unread
Actions.queueTask(task)
Actions.popSheet()
e.stopPropagation()

View file

@ -13,6 +13,7 @@ classNames = require 'classnames'
Thread,
CanvasUtils,
TaskFactory,
ChangeUnreadTask,
WorkspaceStore,
AccountStore,
CategoryStore,
@ -193,8 +194,10 @@ class ThreadList extends React.Component
'application:archive-item': @_onArchiveItem
'application:delete-item': @_onDeleteItem
'application:star-item': @_onStarItem
'application:mark-important': @_onSetImportantItem
'application:mark-unimportant': @_onSetUnimportantItem
'application:mark-important': @_onMarkImportantItem
'application:mark-unimportant': @_onMarkUnimportantItem
'application:mark-as-unread': @_onMarkUnreadItem
'application:mark-as-read': @_onMarkReadItem
'application:remove-and-previous': =>
@_shift(offset: 1, afterRunning: @_onRemoveFromView)
'application:remove-and-next': =>
@ -284,10 +287,10 @@ class ThreadList extends React.Component
task = TaskFactory.taskForInvertingStarred({threads})
Actions.queueTask(task)
_onSetImportantItem: =>
_onMarkImportantItem: =>
@_setImportant(true)
_onSetUnimportantItem: =>
_onMarkUnimportantItem: =>
@_setImportant(false)
_setImportant: (important) =>
@ -302,6 +305,21 @@ class ThreadList extends React.Component
Actions.queueTask(task)
_onMarkReadItem: =>
@_setUnread(false)
_onMarkUnreadItem: =>
@_setUnread(true)
_setUnread: (unread) =>
threads = @_threadsForKeyboardAction()
return unless threads
task = new ChangeUnreadTask
threads: threads
unread: unread
Actions.queueTask(task)
Actions.popSheet()
_onRemoveFromView: =>
threads = @_threadsForKeyboardAction()
backspaceDelete = NylasEnv.config.get('core.reading.backspaceDelete')