From 20b52c17a8dbb5d9010b245f3dcf04775d746e78 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Tue, 8 Mar 2016 21:58:27 -0800 Subject: [PATCH] Show "Download Complete" notification When torrent download finishes and window is not focused, notify the user. --- renderer/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/renderer/index.js b/renderer/index.js index 112f3381..3e4e3afb 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -400,6 +400,7 @@ function addTorrentEvents (torrent) { state.dock.badge += 1 } + showDoneNotification(torrent) update() } } @@ -571,3 +572,16 @@ function onError (err) { function onWarning (err) { console.log('warning: %s', err.message) } + +function showDoneNotification (torrent) { + console.log(state.window.isFocused) + if (state.window.isFocused) return + + var notif = new window.Notification('Download Complete', { + body: torrent.name + }) + + notif.onclick = function () { + window.focus() + } +}