diff --git a/app/extensions/torrent/locales/en-US/app.properties b/app/extensions/torrent/locales/en-US/app.properties
index 1168022eccb..70bd72b6162 100644
--- a/app/extensions/torrent/locales/en-US/app.properties
+++ b/app/extensions/torrent/locales/en-US/app.properties
@@ -14,6 +14,7 @@ downloading=Downloading
downloadingTorrent=Downloading Torrent
files=Files
num=#
+downloadFile=Download
torrentStatus=Torrent Status
torrentLoadingInfo=Loading torrent info...
torrentUntitled=Untitled torrent
diff --git a/js/components/sortableTable.js b/js/components/sortableTable.js
index 261c2a4fb9a..9f88867b2fc 100644
--- a/js/components/sortableTable.js
+++ b/js/components/sortableTable.js
@@ -336,14 +336,15 @@ class SortableTable extends React.Component {
'sort-header': true,
'sort-default': this.sortingDisabled || heading === this.props.defaultHeading
}
- headerClasses['heading-' + heading] = true
+ const isString = typeof heading === 'string'
+ if (isString) headerClasses['heading-' + heading] = true
return
{
- typeof heading === 'string'
- ?
- : heading
+ isString
+ ?
+ : heading
}
|
})}
diff --git a/js/webtorrent/components/mediaViewer.js b/js/webtorrent/components/mediaViewer.js
index c8e4598da8d..95588155e3d 100644
--- a/js/webtorrent/components/mediaViewer.js
+++ b/js/webtorrent/components/mediaViewer.js
@@ -25,30 +25,19 @@ module.exports = class MediaViewer extends React.Component {
const fileExt = file && getExtension(file.name)
const isVideo = SUPPORTED_VIDEO_EXTENSIONS.includes(fileExt)
const isAudio = SUPPORTED_AUDIO_EXTENSIONS.includes(fileExt)
+ const fileURL = torrent.serverURL && (torrent.serverURL + '/' + ix)
let content
if (torrent.serverURL == null) {
content =
} else if (isVideo) {
- content = (
-
- )
+ content =
} else if (isAudio) {
- content = (
-
- )
+ content =
} else {
- content = (
-
- )
+ // For security, sandbox and disallow scripts.
+ // We need allow-same-origin so that the iframe can load from http://localhost:...
+ content =
}
return (
diff --git a/js/webtorrent/components/torrentFileList.js b/js/webtorrent/components/torrentFileList.js
index d769f56bdbe..f46e2a5c6f0 100644
--- a/js/webtorrent/components/torrentFileList.js
+++ b/js/webtorrent/components/torrentFileList.js
@@ -3,17 +3,9 @@ const React = require('react')
const SortableTable = require('../../components/sortableTable')
class TorrentFileList extends React.Component {
- constructor () {
- super()
- this.onClick = this.onClick.bind(this)
- }
-
- onClick (file) {
- window.location = this.props.torrentID + '&ix=' + this.props.files.indexOf(file)
- }
-
render () {
- const files = this.props.files
+ const torrent = this.props.torrent
+ const files = torrent && torrent.files
let content
if (files == null) {
@@ -21,22 +13,21 @@ class TorrentFileList extends React.Component {
} else if (files.length === 0) {
content =
} else {
- // TODO(feross): Add context menu support, like History page has.
content = [
[
String(i + 1),
- file.name,
+ {cell: this.renderFileLink(file, false)},
+ {cell: this.renderFileLink(file, true)},
prettierBytes(file.length)
])}
rowObjects={files}
- columnClassNames={['num', 'name', 'size']}
+ columnClassNames={['num', 'name', 'downloadFile', 'size']}
addHoverClass
- stateOwner={this.props.stateOwner}
- onClick={this.onClick} />
+ stateOwner={this.props.stateOwner} />
]
}
@@ -47,6 +38,22 @@ class TorrentFileList extends React.Component {
)
}
+
+ renderFileLink (file, isDownload) {
+ const { torrent, torrentID } = this.props
+ const ix = torrent.files.indexOf(file)
+ if (isDownload) {
+ if (torrent.serverURL) {
+ const httpURL = torrent.serverURL + '/' + ix
+ return ⇩
+ } else {
+ return // No download links until the server is ready
+ }
+ } else {
+ const magnetURL = torrentID + '&ix=' + ix
+ return {file.name}
+ }
+ }
}
module.exports = TorrentFileList
diff --git a/js/webtorrent/components/torrentViewer.js b/js/webtorrent/components/torrentViewer.js
index ed68c6b58c4..6e19ea6ec05 100644
--- a/js/webtorrent/components/torrentViewer.js
+++ b/js/webtorrent/components/torrentViewer.js
@@ -60,7 +60,7 @@ class TorrentViewer extends React.Component {
{legalNotice}
diff --git a/less/webtorrent.less b/less/webtorrent.less
index 29eb2c5b618..7fd993d2de8 100644
--- a/less/webtorrent.less
+++ b/less/webtorrent.less
@@ -55,8 +55,16 @@
width: 60px;
}
+ .heading-downloadFile {
+ width: 100px;
+ }
+
.heading-size {
- width: 120px;
+ width: 100px;
+ }
+
+ a {
+ text-decoration: none;
}
}
}