Mailspring/internal_packages/message-list/lib/message-toolbar-items.cjsx
Ben Gotow d15b5080fb fix(stores): FocusedThreadStore, FocusedTagStore, speed improvements
Summary:
ThreadStore is now in the thread-list package.

Account sidebar no longer has random stuff dealing with search, no longer maintains selection apart from FocusedTagStore

Thread nav buttons are in the thread package

Account sidebar pulls selection from FocusedTagStore, no longer fires an Action to select Inbox, which was weird

Thread store is in thread-list package. No longer has any selection concept -> moved to FocusedThreadStore. Also looks at database changes to do "shallow" updates when only threads and not messages have changed, or when only messages of a few...

...threads have changed.

WorkspaceStore now handles both pushing AND popping the thread sheet. So all sheet behavior is here.

ThreadStore => FocusedThreadStore, selectThreadId => selectThread

Include all models in inbox-exports

It actually takes a long time to call Promise.reject because Bluebird generates stack traces. Resolve with false instead (100msec faster!)

Cache the model class map. All the requires take ~20msec per call to this method

ThreadList looks at FocusedThreadStore for selection

FocusedThreadStore, FocusedTagStore

Updated specs

Test Plan: Run tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://review.inboxapp.com/D1384
2015-03-31 17:19:17 -07:00

90 lines
2.6 KiB
CoffeeScript

_ = require 'underscore-plus'
React = require 'react'
{Actions, Utils, FocusedThreadStore, WorkspaceStore} = require 'inbox-exports'
{RetinaImg} = require 'ui-components'
# Note: These always have a thread, but only sometimes get a
# message, depending on where in the UI they are being displayed.
ReplyButton = React.createClass
render: ->
<button className="btn btn-toolbar"
data-tooltip="Reply"
onClick={@_onReply}>
<RetinaImg name="toolbar-reply.png" />
</button>
_onReply: (e) ->
return unless Utils.nodeIsVisible(e.currentTarget)
Actions.composeReply(threadId: FocusedThreadStore.threadId())
e.stopPropagation()
ReplyAllButton = React.createClass
render: ->
<button className="btn btn-toolbar"
data-tooltip="Reply All"
onClick={@_onReplyAll}>
<RetinaImg name="toolbar-reply-all.png" />
</button>
_onReplyAll: (e) ->
return unless Utils.nodeIsVisible(e.currentTarget)
Actions.composeReplyAll(threadId: FocusedThreadStore.threadId())
e.stopPropagation()
ForwardButton = React.createClass
render: ->
<button className="btn btn-toolbar"
data-tooltip="Forward"
onClick={@_onForward}>
<RetinaImg name="toolbar-forward.png" />
</button>
_onForward: (e) ->
return unless Utils.nodeIsVisible(e.currentTarget)
Actions.composeForward(threadId: FocusedThreadStore.threadId())
e.stopPropagation()
ArchiveButton = React.createClass
render: ->
<button className="btn btn-toolbar btn-archive"
data-tooltip="Archive"
onClick={@_onArchive}>
<RetinaImg name="toolbar-archive.png" />
</button>
_onArchive: (e) ->
return unless Utils.nodeIsVisible(e.currentTarget)
if WorkspaceStore.selectedLayoutMode() is "list"
Actions.archiveCurrentThread()
else if WorkspaceStore.selectedLayoutMode() is "split"
Actions.archiveAndNext()
e.stopPropagation()
module.exports =
MessageToolbarItems = React.createClass
getInitialState: ->
threadIsSelected: FocusedThreadStore.threadId()?
render: ->
classes = React.addons.classSet
"message-toolbar-items": true
"hidden": !@state.threadIsSelected
<div className={classes}>
<ArchiveButton ref="archiveButton" />
</div>
componentDidMount: ->
@_unsubscribers = []
@_unsubscribers.push FocusedThreadStore.listen @_onChange
componentWillUnmount: ->
unsubscribe() for unsubscribe in @_unsubscribers
_onChange: -> _.defer =>
return unless @isMounted()
@setState
threadIsSelected: FocusedThreadStore.threadId()?