Handle command line arguments
This commit is contained in:
parent
e70e32c5f8
commit
afe5151e28
1 changed files with 10 additions and 6 deletions
|
|
@ -8,6 +8,8 @@ var shortcuts = require('./shortcuts')
|
|||
var windows = require('./windows')
|
||||
var registerProtocolHandler = require('./register-protocol-handler')
|
||||
|
||||
var argv = process.argv.slice(2)
|
||||
|
||||
app.on('open-file', onOpen)
|
||||
app.on('open-url', onOpen)
|
||||
|
||||
|
|
@ -21,6 +23,12 @@ app.on('ready', function () {
|
|||
registerProtocolHandler()
|
||||
})
|
||||
|
||||
app.on('ipcReady', function () {
|
||||
argv.forEach(function (torrentId) {
|
||||
windows.main.send('dispatch', 'onOpen', torrentId)
|
||||
})
|
||||
})
|
||||
|
||||
app.on('before-quit', function () {
|
||||
app.isQuitting = true
|
||||
})
|
||||
|
|
@ -44,12 +52,8 @@ ipc.init()
|
|||
function onOpen (e, torrentId) {
|
||||
e.preventDefault()
|
||||
if (app.ipcReady) {
|
||||
onReadyOpen()
|
||||
} else {
|
||||
app.on('ipcReady', onReadyOpen)
|
||||
}
|
||||
function onReadyOpen () {
|
||||
windows.main.send('dispatch', 'onOpen', torrentId)
|
||||
windows.main.focus()
|
||||
} else {
|
||||
argv.push(torrentId)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue