allow the main process to dispatch any event to the renderer
This commit is contained in:
@@ -37,5 +37,5 @@ ipc.init()
|
|||||||
|
|
||||||
function onOpen (e, torrentId) {
|
function onOpen (e, torrentId) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
windows.main.send('addTorrent', torrentId)
|
windows.main.send('dispatch', 'addTorrent', torrentId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ function getMenuTemplate () {
|
|||||||
properties: [ 'openFile', 'openDirectory', 'multiSelections' ]
|
properties: [ 'openFile', 'openDirectory', 'multiSelections' ]
|
||||||
}, function (filenames) {
|
}, function (filenames) {
|
||||||
if (!Array.isArray(filenames)) return
|
if (!Array.isArray(filenames)) return
|
||||||
windows.main.send('seed', filenames)
|
windows.main.send('dispatch', 'seed', filenames)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -99,7 +99,7 @@ function getMenuTemplate () {
|
|||||||
}, function (filenames) {
|
}, function (filenames) {
|
||||||
if (!Array.isArray(filenames)) return
|
if (!Array.isArray(filenames)) return
|
||||||
filenames.forEach(function (filename) {
|
filenames.forEach(function (filename) {
|
||||||
windows.main.send('addTorrent', filename)
|
windows.main.send('dispatch', 'addTorrent', filename)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,12 +210,8 @@ function dispatch (action, ...args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupIpc () {
|
function setupIpc () {
|
||||||
ipcRenderer.on('addTorrent', function (e, torrentId) {
|
ipcRenderer.on('dispatch', function (e, action, ...args) {
|
||||||
dispatch('addTorrent', torrentId)
|
dispatch(action, ...args)
|
||||||
})
|
|
||||||
|
|
||||||
ipcRenderer.on('seed', function (e, files) {
|
|
||||||
dispatch('seed', files)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on('fullscreenChanged', function (e, isFullScreen) {
|
ipcRenderer.on('fullscreenChanged', function (e, isFullScreen) {
|
||||||
|
|||||||
Reference in New Issue
Block a user