Drag drop: subtitles only in video screen, torrents only in home screen

This commit is contained in:
DC
2016-05-13 17:11:31 -07:00
parent 461744da5b
commit 5ffa7c4465

View File

@@ -539,18 +539,23 @@ function saveState () {
function onOpen (files) { function onOpen (files) {
if (!Array.isArray(files)) files = [ files ] if (!Array.isArray(files)) files = [ files ]
// All .torrent files? Start downloading // In the player, the only drag-drop function is adding subtitles
if (files.every(isTorrent)) { var isInPlayer = state.location.current().url === 'player'
return files.forEach(addTorrent) if (isInPlayer) {
}
// Playing media and adding subtitles?
if (files.some(isSubtitle) && state.location.current().url === 'player') {
return files.filter(isSubtitle).forEach(addSubtitle) return files.filter(isSubtitle).forEach(addSubtitle)
} }
// Show the Create Torrent screen. Let's seed those files. // Otherwise, you can only drag-drop onto the home screen
if (files.length > 0) showCreateTorrent(files) 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) { function isTorrent (file) {
@@ -566,12 +571,6 @@ function isSubtitle (file) {
return ext === '.srt' || ext === '.vtt' 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 // Gets a torrent summary {name, infoHash, status} from state.saved.torrents
// Returns undefined if we don't know that infoHash // Returns undefined if we don't know that infoHash
function getTorrentSummary (torrentKey) { function getTorrentSummary (torrentKey) {