From 44efa6138e79ff06beb510be0c051191b74dc2ba Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Tue, 19 Jun 2018 00:20:52 +0300 Subject: [PATCH] fix(download): crash on download page click in some cases #34 --- src/app/download-page.js | 2 +- src/app/torrent.js | 5 ++++- src/background/api.js | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/download-page.js b/src/app/download-page.js index 2b5554b..781d788 100644 --- a/src/app/download-page.js +++ b/src/app/download-page.js @@ -43,7 +43,7 @@ export default class TopPage extends Page { { window.router('/') }} /> - + { this.downloads.map((download, index) => { return diff --git a/src/app/torrent.js b/src/app/torrent.js index 75be720..439a4ef 100644 --- a/src/app/torrent.js +++ b/src/app/torrent.js @@ -218,7 +218,10 @@ export default class Torrent extends Component { } render() { - const torrent = this.props.torrent; + const torrent = this.props.torrent; + if(!torrent) + return null // can try draw null torrent (for example on downloading not started) + let torrentRating = -1 if(torrent.good > 0 || torrent.bad > 0) torrentRating = Math.round(rating(torrent.good, torrent.bad) * 100); diff --git a/src/background/api.js b/src/background/api.js index 934ac04..f5a5516 100644 --- a/src/background/api.js +++ b/src/background/api.js @@ -626,6 +626,7 @@ module.exports = async ({ torrentClient.remove(id, (err) => { if(err) { + console.log('download removing error', err) if(callback) callback(false) return