Cleanup argument handling in main
This commit is contained in:
@@ -103,13 +103,12 @@ function onOpen (e, torrentId) {
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
if (app.ipcReady) {
|
if (app.ipcReady) {
|
||||||
windows.main.dispatch('onOpen', torrentId)
|
|
||||||
// Magnet links opened from Chrome won't focus the app without a setTimeout.
|
// Magnet links opened from Chrome won't focus the app without a setTimeout.
|
||||||
// The confirmation dialog Chrome shows causes Chrome to steal back the focus.
|
// The confirmation dialog Chrome shows causes Chrome to steal back the focus.
|
||||||
// Electron issue: https://github.com/atom/electron/issues/4338
|
// Electron issue: https://github.com/atom/electron/issues/4338
|
||||||
setTimeout(function () {
|
setTimeout(() => windows.main.show(), 100)
|
||||||
windows.main.show()
|
|
||||||
}, 100)
|
processArgv([ torrentId ])
|
||||||
} else {
|
} else {
|
||||||
argv.push(torrentId)
|
argv.push(torrentId)
|
||||||
}
|
}
|
||||||
@@ -133,7 +132,7 @@ function sliceArgv (argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processArgv (argv) {
|
function processArgv (argv) {
|
||||||
var paths = []
|
var torrentIds = []
|
||||||
argv.forEach(function (arg) {
|
argv.forEach(function (arg) {
|
||||||
if (arg === '-n') {
|
if (arg === '-n') {
|
||||||
dialog.openSeedDirectory()
|
dialog.openSeedDirectory()
|
||||||
@@ -145,10 +144,10 @@ function processArgv (argv) {
|
|||||||
// Ignore OS X launchd "process serial number" argument
|
// Ignore OS X launchd "process serial number" argument
|
||||||
// Issue: https://github.com/feross/webtorrent-desktop/issues/214
|
// Issue: https://github.com/feross/webtorrent-desktop/issues/214
|
||||||
} else {
|
} else {
|
||||||
paths.push(arg)
|
torrentIds.push(arg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (paths.length > 0) {
|
if (torrentIds.length > 0) {
|
||||||
windows.main.dispatch('onOpen', paths)
|
windows.main.dispatch('onOpen', torrentIds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user