diff --git a/main/index.js b/main/index.js index 73dbfe38..1d120f86 100644 --- a/main/index.js +++ b/main/index.js @@ -103,13 +103,12 @@ function onOpen (e, torrentId) { e.preventDefault() if (app.ipcReady) { - windows.main.dispatch('onOpen', torrentId) // 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. // Electron issue: https://github.com/atom/electron/issues/4338 - setTimeout(function () { - windows.main.show() - }, 100) + setTimeout(() => windows.main.show(), 100) + + processArgv([ torrentId ]) } else { argv.push(torrentId) } @@ -133,7 +132,7 @@ function sliceArgv (argv) { } function processArgv (argv) { - var paths = [] + var torrentIds = [] argv.forEach(function (arg) { if (arg === '-n') { dialog.openSeedDirectory() @@ -145,10 +144,10 @@ function processArgv (argv) { // Ignore OS X launchd "process serial number" argument // Issue: https://github.com/feross/webtorrent-desktop/issues/214 } else { - paths.push(arg) + torrentIds.push(arg) } }) - if (paths.length > 0) { - windows.main.dispatch('onOpen', paths) + if (torrentIds.length > 0) { + windows.main.dispatch('onOpen', torrentIds) } }