From 4fc95110b96c5516f5c70051d6d2f3403b8bb369 Mon Sep 17 00:00:00 2001 From: DC Date: Fri, 11 Nov 2016 17:26:50 -0800 Subject: [PATCH] Torrent Viewer UI bugfixes ImmutableComponent -> React.Component Fix NaNs remaining bug --- js/webtorrent/components/torrentFileList.js | 7 +++---- js/webtorrent/components/torrentStats.js | 8 +++++--- js/webtorrent/entry.js | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/js/webtorrent/components/torrentFileList.js b/js/webtorrent/components/torrentFileList.js index 149c71b7f24..8bafc51466c 100644 --- a/js/webtorrent/components/torrentFileList.js +++ b/js/webtorrent/components/torrentFileList.js @@ -1,16 +1,15 @@ const prettierBytes = require('prettier-bytes') - -const ImmutableComponent = require('../../components/immutableComponent') +const React = require('react') const SortableTable = require('../../components/sortableTable') -class TorrentFileList extends ImmutableComponent { +class TorrentFileList extends React.Component { constructor () { super() this.onClick = this.onClick.bind(this) } onClick (file) { - window.location = this.props.torrentID + '&ix=' + file.offset + window.location = this.props.torrentID + '&ix=' + this.props.files.indexOf(file) } render () { diff --git a/js/webtorrent/components/torrentStats.js b/js/webtorrent/components/torrentStats.js index 922adaa28ca..d78edd38c20 100644 --- a/js/webtorrent/components/torrentStats.js +++ b/js/webtorrent/components/torrentStats.js @@ -1,8 +1,7 @@ const prettierBytes = require('prettier-bytes') +const React = require('react') -const ImmutableComponent = require('../../components/immutableComponent') - -class TorrentStats extends ImmutableComponent { +class TorrentStats extends React.Component { render () { const torrent = this.props.torrent const errorMessage = this.props.errorMessage @@ -51,6 +50,9 @@ class TorrentStats extends ImmutableComponent { } function renderEta () { + if (torrent.timeRemaining === Infinity) return // Zero download speed + if (torrent.downloaded === torrent.length) return // Already done + const rawEta = torrent.timeRemaining / 1000 const hours = Math.floor(rawEta / 3600) % 24 const minutes = Math.floor(rawEta / 60) % 60 diff --git a/js/webtorrent/entry.js b/js/webtorrent/entry.js index b76a9528344..e6217439e28 100644 --- a/js/webtorrent/entry.js +++ b/js/webtorrent/entry.js @@ -112,8 +112,8 @@ class TorrentViewer extends React.Component { let fileContent if (state.torrent && ix) { - fileContent = state.server != null - ?