Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Torrent Viewer UI bugfixes
Browse files Browse the repository at this point in the history
ImmutableComponent -> React.Component

Fix NaNs remaining bug
  • Loading branch information
dcposch committed Nov 12, 2016
1 parent 704c560 commit 4fc9511
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
7 changes: 3 additions & 4 deletions js/webtorrent/components/torrentFileList.js
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down
8 changes: 5 additions & 3 deletions js/webtorrent/components/torrentStats.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions js/webtorrent/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ class TorrentViewer extends React.Component {

let fileContent
if (state.torrent && ix) {
fileContent = state.server != null
? <iframe src={state.server + '/' + ix} sandbox='allow-same-origin' />
fileContent = state.torrent.serverURL != null
? <iframe src={state.torrent.serverURL + '/' + ix} sandbox='allow-same-origin' />
: <div>Loading...</div>
}

Expand Down

0 comments on commit 4fc9511

Please sign in to comment.