Skip to content

Commit

Permalink
feat(downloading): download speed
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed Jun 26, 2018
1 parent e1f83a6 commit f9ac98f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
29 changes: 17 additions & 12 deletions src/app/torrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ export default class Torrent extends Component {
super(props)
if(props.download)
{
const { progress, downloaded, speed } = props.download
const { progress, downloaded, downloadSpeed } = props.download
this.state.downloadProgress = {
progress, downloaded, speed
progress, downloaded, downloadSpeed
}
}
}
Expand Down Expand Up @@ -268,15 +268,6 @@ export default class Torrent extends Component {
formatBytes(torrent.size, 1) + ' (' + torrent.files + ' files)'
}
</div>
{
this.state.downloading
&&
<LinearProgress
style={{width: '44%', marginLeft: 20}}
mode="determinate"
value={this.state.downloadProgress && (this.state.downloadProgress.progress ? this.state.downloadProgress.progress : 0) * 100}
/>
}
</div>
{
torrent.path && torrent.path.length > 0
Expand Down Expand Up @@ -312,7 +303,21 @@ export default class Torrent extends Component {
/>
<div className='row center pad0-5 fs0-85 text-nowrap' style={{color: torrentRating >= 50 ? '#00E676' : '#FF3D00', width: '190px'}}>{__('Torrent rating')}: {torrentRating}%</div>
</div>
}
}
{
this.state.downloading
&&
<div className='row w100p inline text-nowrap' style={{maxWidth: 580}}>
<div style={{marginRight: 5, color: 'rgb(0, 188, 212)'}}>{__('downloading')}: </div>
<LinearProgress
style={{height: '5px', width: '44%', marginTop: 2}}
mode="determinate"
value={this.state.downloadProgress && (this.state.downloadProgress.progress ? this.state.downloadProgress.progress : 0) * 100}
/>
<div className='pad0-75' style={{marginLeft: 20}} style={{color: 'rgb(0, 188, 212)'}}>{this.state.downloadProgress && (this.state.downloadProgress.progress * 100).toFixed(1)}%</div>
<div style={{marginLeft: 5, color: 'rgb(0, 188, 212)'}}>{this.state.downloadProgress && formatBytes(this.state.downloadProgress.downloadSpeed || 0, 0)}/s</div>
</div>
}
</div>
</a>
}
Expand Down
4 changes: 2 additions & 2 deletions src/background/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ module.exports = async ({
send('downloadProgress', torrent.infoHash, {
received: bytes,
downloaded: torrent.downloaded,
speed: torrent.downloadSpeed,
downloadSpeed: torrent.downloadSpeed,
progress: torrent.progress,
timeRemaining: torrent.timeRemaining
})
Expand Down Expand Up @@ -648,7 +648,7 @@ module.exports = async ({
received: torrent.received,
downloaded: torrent.downloaded,
progress: torrent.progress,
speed: torrent.downloadSpeed
downloadSpeed: torrent.downloadSpeed
})))
})

Expand Down

0 comments on commit f9ac98f

Please sign in to comment.