Only show play button for torrents that are playable

This commit is contained in:
DC
2016-04-06 02:24:50 -07:00
parent 08a806a643
commit aac862cddf
2 changed files with 16 additions and 3 deletions

View File

@@ -1,7 +1,8 @@
module.exports = {
isPlayable,
isVideo,
isAudio
isAudio,
isPlayableTorrent
}
var path = require('path')
@@ -22,3 +23,7 @@ function isAudio (file) {
var ext = path.extname(file.name)
return ['.mp3', '.aac', '.ogg', '.wav'].indexOf(ext) !== -1
}
function isPlayableTorrent (torrentSummary) {
return torrentSummary.files && torrentSummary.files.some(isPlayable)
}

View File

@@ -137,14 +137,22 @@ function TorrentList (state) {
downloadTooltip = 'Click to start torrenting.'
}
return hx`
<div class='buttons'>
// Only show the play button for torrents that contain playable media
var playButton
if (TorrentPlayer.isPlayableTorrent(torrentSummary)) {
playButton = hx`
<i.btn.icon.play
title=${playTooltip}
class=${playClass}
onclick=${dispatcher('play', infoHash)}>
${playIcon}
</i>
`
}
return hx`
<div class='buttons'>
${playButton}
<i.btn.icon.download
class=${torrentSummary.status}
title=${downloadTooltip}