import _ from 'underscore'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { ListensToObservable } from 'mailspring-component-kit'; import ThreadListStore from './thread-list-store'; function getObservable() { return ThreadListStore.selectionObservable().map(items => items.length); } function getStateFromObservable(selectionCount) { if (!selectionCount) { return { selectionCount: 0 }; } return { selectionCount }; } class SelectedItemsStack extends Component { static displayName = 'SelectedItemsStack'; static propTypes = { selectionCount: PropTypes.number, }; static containerRequired = false; onClearSelection = () => { ThreadListStore.dataSource().selection.clear(); }; render() { const { selectionCount } = this.props; if (selectionCount <= 1) { return ; } const cardCount = Math.min(5, selectionCount); return (