From 86f4ad29a65aa664ac632349cd21a4f8f1a5a10a Mon Sep 17 00:00:00 2001 From: Nate Goldman Date: Sat, 5 Mar 2016 11:40:15 -0800 Subject: [PATCH] fix renderering errors giving prettyBytes anything but a number causes the torrent-list render to fail --- renderer/views/torrent-list.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/renderer/views/torrent-list.js b/renderer/views/torrent-list.js index 718438d4..35cc5943 100644 --- a/renderer/views/torrent-list.js +++ b/renderer/views/torrent-list.js @@ -49,17 +49,28 @@ function renderTorrent (state, dispatch, torrent) { // Renders the torrent name and download progress function renderTorrentMetadata (torrent) { + var progressPercent = 0 + var progressBytes = 0 + + if (torrent.progress) { + progressPercent = Math.floor(100 * torrent.progress) + } + + if (torrent.length && torrent.progress) { + progressBytes = torrent.length * torrent.progress + } + return hx`
${torrent.name || 'Loading torrent...'}
- ${Math.floor(100 * torrent.progress)}% - ${prettyBytes(torrent.length * torrent.progress)} / ${prettyBytes(torrent.length)} + ${progressPercent}% + ${prettyBytes(progressBytes)} / ${prettyBytes(torrent.length || 0)}
${getFilesLength()} ${getPeers()} - ↓ ${prettyBytes(torrent.downloadSpeed)}/s - ↑ ${prettyBytes(torrent.uploadSpeed)}/s + ↓ ${prettyBytes(torrent.downloadSpeed || 0)}/s + ↑ ${prettyBytes(torrent.uploadSpeed || 0)}/s
`