mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-23 16:56:08 +08:00
d3482419f1
Summary: Except for send tasks, place notifications of syncback tasks inside the expanded sync details. Addresses T7458 Test Plan: tested locally Reviewers: juan, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D3693
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
import _ from 'underscore';
|
|
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 items = _.pairs(counts).map(([label, count]) => {
|
|
return (
|
|
<div className="item" key={label}>
|
|
<div className="inner">
|
|
<span className="count">({count.toLocaleString()})</span>
|
|
{label}
|
|
</div>
|
|
</div>
|
|
)
|
|
});
|
|
|
|
if (items.length === 0) {
|
|
items.push(
|
|
<div className="item" key="no-labels">
|
|
<div className="inner">
|
|
Applying tasks
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
{items}
|
|
</div>
|
|
)
|
|
}
|
|
}
|