diff --git a/main/ipc.js b/main/ipc.js index 8c76c987..c9ef307d 100644 --- a/main/ipc.js +++ b/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 } diff --git a/renderer/index.js b/renderer/index.js index 24541a5b..ed42b771 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -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')