fix(downloading): always show downloading on list even if download not started
This commit is contained in:
parent
c321286d6c
commit
6bd4d69e4c
@ -45,8 +45,9 @@ export default class TopPage extends Page {
|
|||||||
}} />
|
}} />
|
||||||
<List style={{paddingBottom: '70px', minWidth: '60%'}} className='animated recent-torrents'>
|
<List style={{paddingBottom: '70px', minWidth: '60%'}} className='animated recent-torrents'>
|
||||||
{
|
{
|
||||||
this.downloads.map((download, index) => {
|
this.downloads.map((torrentDownload, index) => {
|
||||||
return <TorrentLine key={index} torrent={download.torrentObject} download={download} />
|
const {torrentObject: torrent, ...download} = torrentDownload
|
||||||
|
return <TorrentLine key={index} torrent={torrent} download={download} />
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</List>
|
</List>
|
||||||
|
@ -171,6 +171,7 @@ export default class Torrent extends Component {
|
|||||||
this.state.downloadProgress = {
|
this.state.downloadProgress = {
|
||||||
progress, downloaded, downloadSpeed
|
progress, downloaded, downloadSpeed
|
||||||
}
|
}
|
||||||
|
this.state.downloading = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
componentDidMount()
|
componentDidMount()
|
||||||
@ -303,21 +304,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 className='row center pad0-5 fs0-85 text-nowrap' style={{color: torrentRating >= 50 ? '#00E676' : '#FF3D00', width: '190px'}}>{__('Torrent rating')}: {torrentRating}%</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.state.downloading
|
this.state.downloading
|
||||||
&&
|
&&
|
||||||
<div className='row w100p inline text-nowrap' style={{maxWidth: 580}}>
|
<div className='row w100p inline text-nowrap' style={{maxWidth: 580}}>
|
||||||
<div style={{marginRight: 5, color: 'rgb(0, 188, 212)'}}>{__('downloading')}: </div>
|
<div style={{marginRight: 5, color: 'rgb(0, 188, 212)'}}>{__('downloading')}: </div>
|
||||||
<LinearProgress
|
<LinearProgress
|
||||||
style={{height: '5px', width: '44%', marginTop: 2}}
|
style={{height: '5px', width: '44%', marginTop: 2}}
|
||||||
mode="determinate"
|
mode="determinate"
|
||||||
value={this.state.downloadProgress && (this.state.downloadProgress.progress ? this.state.downloadProgress.progress : 0) * 100}
|
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 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 style={{marginLeft: 5, color: 'rgb(0, 188, 212)'}}>{this.state.downloadProgress && formatBytes(this.state.downloadProgress.downloadSpeed || 0, 0)}/s</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
|
@ -585,31 +585,33 @@ module.exports = async ({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
torrentClient.add(magnet, {path: config.client.downloadPath}, (torrent) =>{
|
const torrent = torrentClient.add(magnet, {path: config.client.downloadPath})
|
||||||
torrentClientHashMap[torrent.infoHash] = magnet
|
torrentClientHashMap[torrent.infoHash] = magnet
|
||||||
torrent.torrentObject = torrentObject
|
torrent.torrentObject = torrentObject
|
||||||
|
|
||||||
|
torrent.on('torrent', () => {
|
||||||
console.log('start downloading', torrent.infoHash)
|
console.log('start downloading', torrent.infoHash)
|
||||||
send('downloading', torrent.infoHash)
|
send('downloading', torrent.infoHash)
|
||||||
|
})
|
||||||
|
|
||||||
torrent.on('done', () => {
|
torrent.on('done', () => {
|
||||||
console.log('download done', torrent.infoHash)
|
console.log('download done', torrent.infoHash)
|
||||||
delete torrentClientHashMap[torrent.infoHash]
|
delete torrentClientHashMap[torrent.infoHash]
|
||||||
send('downloadDone', torrent.infoHash)
|
send('downloadDone', torrent.infoHash)
|
||||||
})
|
})
|
||||||
|
|
||||||
let now = Date.now()
|
let now = Date.now()
|
||||||
torrent.on('download', (bytes) => {
|
torrent.on('download', (bytes) => {
|
||||||
if(Date.now() - now < 100)
|
if(Date.now() - now < 100)
|
||||||
return
|
return
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
|
|
||||||
send('downloadProgress', torrent.infoHash, {
|
send('downloadProgress', torrent.infoHash, {
|
||||||
received: bytes,
|
received: bytes,
|
||||||
downloaded: torrent.downloaded,
|
downloaded: torrent.downloaded,
|
||||||
downloadSpeed: torrent.downloadSpeed,
|
downloadSpeed: torrent.downloadSpeed,
|
||||||
progress: torrent.progress,
|
progress: torrent.progress,
|
||||||
timeRemaining: torrent.timeRemaining
|
timeRemaining: torrent.timeRemaining
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user