diff --git a/src/app/torrent-page.js b/src/app/torrent-page.js index e29b7bf..59975c7 100644 --- a/src/app/torrent-page.js +++ b/src/app/torrent-page.js @@ -404,7 +404,7 @@ export default class TorrentPage extends Page { { diff --git a/src/app/torrent.js b/src/app/torrent.js index c319113..faeb00c 100644 --- a/src/app/torrent.js +++ b/src/app/torrent.js @@ -169,11 +169,14 @@ export default class Torrent extends Component { } window.torrentSocket.on('downloading', this.downloading); - this.downloadDone = (hash) => { + this.downloadDone = (hash, canceled) => { if(this.props.torrent.hash != hash) return; - this.setState({downloading: false}) + this.setState({ + downloading: false, + askDownloading: !canceled + }) } window.torrentSocket.on('downloadDone', this.downloadDone); @@ -246,7 +249,7 @@ export default class Torrent extends Component { } @@ -312,8 +315,22 @@ export default class Torrent extends Component { : this.state.askDownloading && !this.state.downloading - && + ? + : + this.state.askDownloading && this.state.downloading + && + + { + e.preventDefault(); + e.stopPropagation(); + + window.torrentSocket.emit('downloadCancel', torrent.hash) + }} viewBox="0 0 18 18"> + } { const id = torrentClientHashMap[hash] if(!id) { - callback(false) + if(callback) + callback(false) return } torrentClient.remove(id, (err) => { if(err) { - callback(false) + if(callback) + callback(false) return }