Mailspring/internal_packages/thread-list/lib/thread-list-quick-actions.cjsx
Ben Gotow 3e43f45401 perf(drafts): Cache results of running Autolinker, avoid props.children for EmailFrame, fix special case for new draft
Summary:
"results.length" not "result.length".

Eventually I want MessageBodyProcessor to be the public interface to another process which asynchronously runs message body parsing? At the very least, caching the results means that miscelaneous refreshes to the message list don't incur significant string processing cost.

Test Plan: No new tests here

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1898
2015-08-17 16:23:12 -07:00

74 lines
2.5 KiB
CoffeeScript

_ = require 'underscore'
React = require 'react'
{Actions,
Utils,
Thread,
ArchiveThreadHelper,
CategoryStore,
ChangeFolderTask,
ChangeLabelsTask,
NamespaceStore} = require 'nylas-exports'
class ThreadListQuickActions extends React.Component
@displayName: 'ThreadListQuickActions'
@propTypes:
thread: React.PropTypes.object
categoryId: React.PropTypes.string
render: =>
actions = []
actions.push <div key="reply" className="action action-reply" onClick={@_onReply}></div>
actions.push <div key="fwd" className="action action-forward" onClick={@_onForward}></div>
if @_shouldDisplayArchiveButton()
actions.push <div key="archive" className="action action-archive" onClick={@_onArchive}></div>
else if NamespaceStore.current().usesLabels() and @props.categoryId == CategoryStore.getStandardCategory('all').id
actions.push <div key="trash" className="action action-trash" onClick={@_onTrash}></div>
<div className="inner">
{actions}
</div>
shouldComponentUpdate: (newProps, newState) ->
newProps.thread.id isnt @props?.thread.id
_shouldDisplayArchiveButton: =>
if @props.categoryId != CategoryStore.getStandardCategory('archive')?.id and @props.categoryId != CategoryStore.getStandardCategory('trash')?.id
if NamespaceStore.current().usesLabels()
if @props.thread.labels.length == 1 and (@props.thread.labels[0].name == "archive" or @props.thread.labels[0].name == "all")
return false
return true
else if @props.thread.folders.length == 1 and @props.thread.folders[0].name == "archive"
return false
return true
return false
_onTrash: (event) =>
params =
thread: @props.thread,
labelsToRemove: [CategoryStore.byId(@props.categoryId)],
labelsToAdd: [CategoryStore.getStandardCategory("trash")]
Actions.queueTask(new ChangeLabelsTask(params))
# Don't trigger the thread row click
event.stopPropagation()
_onForward: (event) =>
Actions.composeForward({thread: @props.thread, popout: true})
# Don't trigger the thread row click
event.stopPropagation()
_onReply: (event) =>
Actions.composeReply({thread: @props.thread, popout: true})
# Don't trigger the thread row click
event.stopPropagation()
_onArchive: (event) =>
archiveTask = ArchiveThreadHelper.getArchiveTask([@props.thread])
Actions.queueTask(archiveTask)
# Don't trigger the thread row click
event.stopPropagation()
module.exports = ThreadListQuickActions