import React, {PropTypes} from 'react' import ReactCSSTransitionGroup from 'react-addons-css-transition-group' import {Rx, FocusedContentStore} from 'nylas-exports' import ThreadListStore from './thread-list-store' import InjectsToolbarButtons, {ToolbarRole} from './injects-toolbar-buttons' function getObservable() { return ( Rx.Observable.combineLatest( Rx.Observable.fromStore(FocusedContentStore), ThreadListStore.selectionObservable(), (store, items) => ({focusedThread: store.focused('thread'), items}) ) .map(({focusedThread, items}) => { if (focusedThread) { return [focusedThread] } return items }) ) } const MessageListToolbar = ({items, injectedButtons}) => { const shouldRender = items.length > 0 return ( {shouldRender ? injectedButtons : undefined} ) } MessageListToolbar.displayName = 'MessageListToolbar'; MessageListToolbar.propTypes = { items: PropTypes.array, injectedButtons: PropTypes.element, }; const toolbarProps = { getObservable, extraRoles: [`MessageList:${ToolbarRole}`], } export default InjectsToolbarButtons(MessageListToolbar, toolbarProps)