Show "Download Complete" notification

When torrent download finishes and window is not focused, notify the
user.
This commit is contained in:
Feross Aboukhadijeh
2016-03-08 21:58:27 -08:00
parent 56536ad55e
commit 20b52c17a8

View File

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