Only show ETA & transfer speeds if file is transferring

This commit is contained in:
John Furrow
2016-04-23 19:10:39 -07:00
parent 751e305292
commit 5e8640457f
7 changed files with 61 additions and 92 deletions
@@ -16,7 +16,7 @@ class SettingsButton extends React.Component {
return (
<a className="sidebar__icon-button sidebar__icon-button--settings"
onClick={this.handleSettingsButtonClick}>
<SettingsIcon />
Settings <SettingsIcon />
</a>
);
}
@@ -57,7 +57,7 @@ class SpeedLimitDropdown extends React.Component {
getDropdownHeader() {
return (
<a className="client-stat--limits">
<a className="sidebar__icon-button sidebar__icon-button--limits">
<LimitsIcon /> Speed Limits
</a>
);
@@ -144,7 +144,6 @@ class SpeedLimitDropdown extends React.Component {
}
render() {
// return <span>hi</span>;
return (
<SidebarItem modifier="speed-limit">
<Dropdown
@@ -52,6 +52,7 @@ export default class Torrent extends React.Component {
let downloadTotal = format.data(torrent.downloadTotal);
let eta = format.eta(torrent.eta);
let ratio = format.ratio(torrent.ratio);
let secondaryDetails = [];
let totalSize = format.data(torrent.sizeBytes);
let uploadRate = format.data(torrent.uploadRate, '/s');
let uploadTotal = format.data(torrent.uploadTotal);
@@ -59,6 +60,36 @@ export default class Torrent extends React.Component {
let torrentClasses = torrentStatusClasses(torrent, this.props.selected ? 'is-selected' : null, 'torrent');
let torrentStatusIcon = torrentStatusIcons(torrent.status);
let isActivelyDownloading = downloadRate.value > 0 || uploadRate.value > 0;
let wasAddedRecently = (Date.now() - added.getTime()) < 1000 * 60 * 10; // Was added in the last 10 minutes.
if (isActivelyDownloading) {
secondaryDetails.push(
<li className="torrent__details--secondary torrent__details--eta"
key="eta">
<span className="torrent__details__icon"><ClockIcon /></span>
{eta}
</li>
);
}
if (isActivelyDownloading || wasAddedRecently) {
secondaryDetails.push(
<li className="torrent__details--secondary torrent__details--speed
torrent__details--speed--download" key="download-rate">
<span className="torrent__details__icon"><DownloadThickIcon /></span>
{downloadRate.value}
<em className="unit">{downloadRate.unit}</em>
</li>,
<li className="torrent__details--secondary torrent__details--speed
torrent__details--speed--upload" key="upload-rate">
<span className="torrent__details__icon"><UploadThickIcon /></span>
{uploadRate.value}
<em className="unit">{uploadRate.unit}</em>
</li>
);
}
return (
<li className={torrentClasses} onClick={this.handleClick}
onContextMenu={this.handleRightClick}>
@@ -66,28 +97,7 @@ export default class Torrent extends React.Component {
<li className="torrent__details--primary text-overflow">
{torrent.name}
</li>
<li className="torrent__details--secondary">
<ul className="torrent__details">
<li className="torrent__details--eta">
<span className="torrent__details__icon"><ClockIcon /></span>
{eta}
</li>
<li className="torrent__details--speed torrent__details--speed--download">
<span className="torrent__details__icon"><DownloadThickIcon /></span>
{downloadRate.value}
<em className="unit">{downloadRate.unit}</em>
</li>
<li className="torrent__details--speed torrent__details--speed--upload">
<span className="torrent__details__icon"><UploadThickIcon /></span>
{uploadRate.value}
<em className="unit">{uploadRate.unit}</em>
</li>
<li className="torrent__details--ratio">
<span className="torrent__details__icon"><RatioIcon /></span>
{ratio}
</li>
</ul>
</li>
{secondaryDetails}
</ul>
<ul className="torrent__details torrent__details--tertiary">
<li className="torrent__details--completed">
@@ -103,6 +113,10 @@ export default class Torrent extends React.Component {
{uploadTotal.value}
<em className="unit">{uploadTotal.unit}</em>
</li>
<li className="torrent__details--ratio">
<span className="torrent__details__icon"><RatioIcon /></span>
{ratio}
</li>
<li className="torrent__details--size">
<span className="torrent__details__icon"><DiskIcon /></span>
{totalSize.value}