15
main/ipc.js
15
main/ipc.js
@@ -70,21 +70,22 @@ function init () {
|
|||||||
shortcuts.unregisterPlayerShortcuts()
|
shortcuts.unregisterPlayerShortcuts()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.on('focusWindow', function (e, windowName) {
|
||||||
|
windows.focusWindow(windows[windowName])
|
||||||
|
})
|
||||||
|
|
||||||
// Capture all events
|
// Capture all events
|
||||||
var oldEmit = ipcMain.emit
|
var oldEmit = ipcMain.emit
|
||||||
ipcMain.emit = function (name, e, ...args) {
|
ipcMain.emit = function (name, e, ...args) {
|
||||||
// Relay messages between the main window and the WebTorrent hidden window
|
// Relay messages between the main window and the WebTorrent hidden window
|
||||||
if (name.startsWith('wt-')) {
|
if (name.startsWith('wt-')) {
|
||||||
var recipient, recipientStr
|
|
||||||
if (e.sender.browserWindowOptions.title === 'webtorrent-hidden-window') {
|
if (e.sender.browserWindowOptions.title === 'webtorrent-hidden-window') {
|
||||||
recipient = windows.main
|
windows.main.send(name, ...args)
|
||||||
recipientStr = 'main'
|
log('webtorrent ipc: sent %s', name)
|
||||||
} else {
|
} else {
|
||||||
recipient = windows.webtorrent
|
windows.webtorrent.send(name, ...args)
|
||||||
recipientStr = 'webtorrent'
|
log('webtorrent ipc: receieved %s', name)
|
||||||
}
|
}
|
||||||
console.log('sending %s to %s', name, recipientStr)
|
|
||||||
recipient.send(name, ...args)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ function torrentDone (torrentKey, torrentInfo) {
|
|||||||
if (!state.window.isFocused) {
|
if (!state.window.isFocused) {
|
||||||
state.dock.badge += 1
|
state.dock.badge += 1
|
||||||
}
|
}
|
||||||
showDoneNotification(torrentKey)
|
showDoneNotification(torrentSummary)
|
||||||
}
|
}
|
||||||
|
|
||||||
update()
|
update()
|
||||||
@@ -974,15 +974,13 @@ function onWarning (err) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showDoneNotification (torrent) {
|
function showDoneNotification (torrent) {
|
||||||
if (state.window.isFocused) return
|
|
||||||
|
|
||||||
var notif = new window.Notification('Download Complete', {
|
var notif = new window.Notification('Download Complete', {
|
||||||
body: torrent.name,
|
body: torrent.name,
|
||||||
silent: true
|
silent: true
|
||||||
})
|
})
|
||||||
|
|
||||||
notif.onclick = function () {
|
notif.onclick = function () {
|
||||||
window.focus()
|
ipcRenderer.send('focusWindow', 'main')
|
||||||
}
|
}
|
||||||
|
|
||||||
playInterfaceSound('DONE')
|
playInterfaceSound('DONE')
|
||||||
|
|||||||
Reference in New Issue
Block a user