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