import {React, Utils} from 'nylas-exports'; export default class SyncbackActivity extends React.Component { static propTypes = { syncbackTasks: React.PropTypes.array, } shouldComponentUpdate(nextProps, nextState) { return !Utils.isEqualReact(nextProps, this.props) || !Utils.isEqualReact(nextState, this.state); } render() { const {syncbackTasks} = this.props; if (!syncbackTasks || syncbackTasks.length === 0) { return false; } const counts = {} this.props.syncbackTasks.forEach((task) => { const label = task.label ? task.label() : null; if (!label) { return; } if (!counts[label]) { counts[label] = 0; } counts[label] += +task.numberOfImpactedItems() }); const ellipses = [1, 2, 3].map((i) => ( .) ); const items = Object.entries(counts).map(([label, count]) => { return (
({count.toLocaleString()}) {label}{ellipses}
) }); if (items.length === 0) { items.push(
Applying tasks
) } return (
{items}
) } }