Clean up showCreateTorrent
This commit is contained in:
@@ -148,7 +148,7 @@ function processArgv (argv) {
|
|||||||
if (pathsToOpen.length > 0) openFilePaths(pathsToOpen)
|
if (pathsToOpen.length > 0) openFilePaths(pathsToOpen)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert paths to {name, path, size} objects, then send to renderer process
|
// Send files to the renderer process
|
||||||
// Opening files means either adding torrents, creating and seeding a torrent
|
// Opening files means either adding torrents, creating and seeding a torrent
|
||||||
// from files, or adding subtitles
|
// from files, or adding subtitles
|
||||||
function openFilePaths (paths) {
|
function openFilePaths (paths) {
|
||||||
|
|||||||
@@ -189,8 +189,7 @@ function showOpenSeedFile () {
|
|||||||
properties: [ 'openFile' ]
|
properties: [ 'openFile' ]
|
||||||
}, function (selectedPaths) {
|
}, function (selectedPaths) {
|
||||||
if (!Array.isArray(selectedPaths)) return
|
if (!Array.isArray(selectedPaths)) return
|
||||||
var selectedPath = selectedPaths[0]
|
windows.main.send('dispatch', 'showCreateTorrent', selectedPaths)
|
||||||
windows.main.send('dispatch', 'showCreateTorrent', selectedPath)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,8 +201,7 @@ function showOpenSeedFiles () {
|
|||||||
properties: [ 'openFile', 'openDirectory' ]
|
properties: [ 'openFile', 'openDirectory' ]
|
||||||
}, function (selectedPaths) {
|
}, function (selectedPaths) {
|
||||||
if (!Array.isArray(selectedPaths)) return
|
if (!Array.isArray(selectedPaths)) return
|
||||||
var selectedPath = selectedPaths[0]
|
windows.main.send('dispatch', 'showCreateTorrent', selectedPaths)
|
||||||
windows.main.send('dispatch', 'showCreateTorrent', selectedPath)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ function dispatch (action, ...args) {
|
|||||||
ipcRenderer.send('showOpenTorrentFile') /* open torrent file */
|
ipcRenderer.send('showOpenTorrentFile') /* open torrent file */
|
||||||
}
|
}
|
||||||
if (action === 'showCreateTorrent') {
|
if (action === 'showCreateTorrent') {
|
||||||
showCreateTorrent(args[0] /* fileOrFolder */)
|
showCreateTorrent(args[0] /* paths */)
|
||||||
}
|
}
|
||||||
if (action === 'createTorrent') {
|
if (action === 'createTorrent') {
|
||||||
createTorrent(args[0] /* options */)
|
createTorrent(args[0] /* options */)
|
||||||
@@ -803,18 +803,18 @@ function startTorrentingSummary (torrentSummary) {
|
|||||||
|
|
||||||
// Shows the Create Torrent page with options to seed a given file or folder
|
// Shows the Create Torrent page with options to seed a given file or folder
|
||||||
function showCreateTorrent (files) {
|
function showCreateTorrent (files) {
|
||||||
if (Array.isArray(files)) {
|
// Files will either be an array of file objects, which we can send directly
|
||||||
if (files.length === 0 || typeof files[0] !== 'string') {
|
// to the create-torrent screen
|
||||||
state.location.go({
|
if (files.length === 0 || typeof files[0] !== 'string') {
|
||||||
url: 'create-torrent',
|
state.location.go({
|
||||||
files: files
|
url: 'create-torrent',
|
||||||
})
|
files: files
|
||||||
return
|
})
|
||||||
}
|
return
|
||||||
} else {
|
|
||||||
files = [files]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ... or it will be an array of mixed file and folder paths. We have to walk
|
||||||
|
// through all the folders and find the files
|
||||||
findFilesRecursive(files, showCreateTorrent)
|
findFilesRecursive(files, showCreateTorrent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user