Merge pull request #310 from feross/notif

Notification Fixes
This commit is contained in:
Feross Aboukhadijeh
2016-04-05 18:39:55 -07:00
2 changed files with 10 additions and 11 deletions

View File

@@ -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
}

View File

@@ -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')