From 461744da5b3e49907c1bea4305e2d434af00d9d2 Mon Sep 17 00:00:00 2001 From: DC Date: Fri, 13 May 2016 16:59:18 -0700 Subject: [PATCH] Allow seeding torrents that contain subtitles Fixes a bug in our drag-drop handling: before, it was impossible to create a torrent containing .torrent, .srt, or .vtt files --- renderer/index.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/renderer/index.js b/renderer/index.js index 55b145f4..511b47f0 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -539,15 +539,18 @@ function saveState () { function onOpen (files) { if (!Array.isArray(files)) files = [ files ] - // .torrent file = start downloading the torrent - files.filter(isTorrent).forEach(addTorrent) + // All .torrent files? Start downloading + if (files.every(isTorrent)) { + return files.forEach(addTorrent) + } - // subtitle file - files.filter(isSubtitle).forEach(addSubtitle) + // Playing media and adding subtitles? + if (files.some(isSubtitle) && state.location.current().url === 'player') { + return files.filter(isSubtitle).forEach(addSubtitle) + } - // everything else = seed these files - var rest = files.filter(not(isTorrent)).filter(not(isSubtitle)) - if (rest.length > 0) showCreateTorrent(rest) + // Show the Create Torrent screen. Let's seed those files. + if (files.length > 0) showCreateTorrent(files) } function isTorrent (file) {