From aac862cddf209913ad47d7e644818a7bcc2d6165 Mon Sep 17 00:00:00 2001 From: DC Date: Wed, 6 Apr 2016 02:24:50 -0700 Subject: [PATCH] Only show play button for torrents that are playable --- renderer/lib/torrent-player.js | 7 ++++++- renderer/views/torrent-list.js | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/renderer/lib/torrent-player.js b/renderer/lib/torrent-player.js index fb32365a..d9a5a75e 100644 --- a/renderer/lib/torrent-player.js +++ b/renderer/lib/torrent-player.js @@ -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) +} diff --git a/renderer/views/torrent-list.js b/renderer/views/torrent-list.js index 11a07aad..d2ea67aa 100644 --- a/renderer/views/torrent-list.js +++ b/renderer/views/torrent-list.js @@ -137,14 +137,22 @@ function TorrentList (state) { downloadTooltip = 'Click to start torrenting.' } - return hx` -
+ // Only show the play button for torrents that contain playable media + var playButton + if (TorrentPlayer.isPlayableTorrent(torrentSummary)) { + playButton = hx` ${playIcon} + ` + } + + return hx` +
+ ${playButton}