diff --git a/internal_packages/message-list/lib/thread-toggle-unread-button.cjsx b/internal_packages/message-list/lib/thread-toggle-unread-button.cjsx index f0f95e45e..8e4140e95 100644 --- a/internal_packages/message-list/lib/thread-toggle-unread-button.cjsx +++ b/internal_packages/message-list/lib/thread-toggle-unread-button.cjsx @@ -1,6 +1,6 @@ React = require 'react' {Actions, FocusedContentStore, ChangeUnreadTask} = require 'nylas-exports' -{RetinaImg} = require 'nylas-component-kit' +{RetinaImg, KeyCommandsRegion} = require 'nylas-component-kit' class ThreadToggleUnreadButton extends React.Component @displayName: "ThreadToggleUnreadButton" @@ -9,18 +9,27 @@ class ThreadToggleUnreadButton extends React.Component render: => fragment = if @props.thread?.unread then "read" else "unread" - + + + + + _globalHandlers: => + 'application:mark-as-unread': (e) => @_setUnread(e, true) + 'application:mark-as-read': (e) => @_setUnread(e, false) _onClick: (e) => + @_setUnread(e, !@props.thread.unread) + + _setUnread: (e, unread)=> task = new ChangeUnreadTask thread: @props.thread - unread: !@props.thread.unread + unread: unread Actions.queueTask(task) Actions.popSheet() e.stopPropagation() diff --git a/internal_packages/message-list/spec/message-toolbar-items-spec.cjsx b/internal_packages/message-list/spec/message-toolbar-items-spec.cjsx index 4f883dc98..2de4a214d 100644 --- a/internal_packages/message-list/spec/message-toolbar-items-spec.cjsx +++ b/internal_packages/message-list/spec/message-toolbar-items-spec.cjsx @@ -49,7 +49,7 @@ describe "MessageToolbarItem marking as unread", -> it "queues a task to change unread status to true", -> spyOn Actions, "queueTask" - ReactTestUtils.Simulate.click React.findDOMNode(markUnreadBtn) + ReactTestUtils.Simulate.click React.findDOMNode(markUnreadBtn).childNodes[0] changeUnreadTask = Actions.queueTask.calls[0].args[0] expect(changeUnreadTask instanceof ChangeUnreadTask).toBe true @@ -58,6 +58,7 @@ describe "MessageToolbarItem marking as unread", -> it "returns to the thread list", -> spyOn Actions, "popSheet" - ReactTestUtils.Simulate.click React.findDOMNode(markUnreadBtn) + ReactTestUtils.Simulate.click React.findDOMNode(markUnreadBtn).childNodes[0] expect(Actions.popSheet).toHaveBeenCalled() + diff --git a/src/components/mail-important-icon.cjsx b/src/components/mail-important-icon.cjsx index a96797231..43935ce85 100644 --- a/src/components/mail-important-icon.cjsx +++ b/src/components/mail-important-icon.cjsx @@ -6,6 +6,7 @@ React = require 'react' ChangeLabelsTask, CategoryStore, AccountStore} = require 'nylas-exports' +{KeyCommandsRegion} = require 'nylas-component-kit' class MailImportantIcon extends React.Component @displayName: 'MailImportantIcon' @@ -38,18 +39,27 @@ class MailImportantIcon extends React.Component isImportant = _.findWhere(@props.thread.labels, {id: importantId})? activeClassname = if isImportant then "active" else "" -
+ +
+
+ + _globalHandlers: => + 'application:mark-as-important': (e) => @_setImportant(e, true) + 'application:mark-as-unimportant': (e) => @_setImportant(e, false) _onToggleImportant: (event) => - importantLabel = CategoryStore.getStandardCategory('important') isImportant = _.findWhere(@props.thread.labels, {id: importantLabel.id})? + @_setImportant(event, !isImportant) - if isImportant - task = new ChangeLabelsTask(thread: @props.thread, labelsToRemove: [importantLabel], labelsToAdd: []) - else + _setImportant: (event, important) => + importantLabel = CategoryStore.getStandardCategory('important') + + if important task = new ChangeLabelsTask(thread: @props.thread, labelsToAdd: [importantLabel], labelsToRemove: []) + else + task = new ChangeLabelsTask(thread: @props.thread, labelsToRemove: [importantLabel], labelsToAdd: []) Actions.queueTask(task)