From 5ffa7c4465a89fbe15974b6108dc1da35201b28e Mon Sep 17 00:00:00 2001 From: DC Date: Fri, 13 May 2016 17:11:31 -0700 Subject: [PATCH] Drag drop: subtitles only in video screen, torrents only in home screen --- renderer/index.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/renderer/index.js b/renderer/index.js index 511b47f0..6c97cf15 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -539,18 +539,23 @@ function saveState () { function onOpen (files) { if (!Array.isArray(files)) files = [ files ] - // All .torrent files? Start downloading - if (files.every(isTorrent)) { - return files.forEach(addTorrent) - } - - // Playing media and adding subtitles? - if (files.some(isSubtitle) && state.location.current().url === 'player') { + // In the player, the only drag-drop function is adding subtitles + var isInPlayer = state.location.current().url === 'player' + if (isInPlayer) { return files.filter(isSubtitle).forEach(addSubtitle) } - // Show the Create Torrent screen. Let's seed those files. - if (files.length > 0) showCreateTorrent(files) + // Otherwise, you can only drag-drop onto the home screen + var isHome = state.location.current().url === 'home' && !state.modal + if (isHome) { + if (files.every(isTorrent)) { + // All .torrent files? Start downloading + files.forEach(addTorrent) + } else { + // Show the Create Torrent screen. Let's seed those files. + showCreateTorrent(files) + } + } } function isTorrent (file) { @@ -566,12 +571,6 @@ function isSubtitle (file) { return ext === '.srt' || ext === '.vtt' } -function not (test) { - return function (...args) { - return !test(...args) - } -} - // Gets a torrent summary {name, infoHash, status} from state.saved.torrents // Returns undefined if we don't know that infoHash function getTorrentSummary (torrentKey) {