Show "Download Complete" notification
When torrent download finishes and window is not focused, notify the user.
This commit is contained in:
@@ -400,6 +400,7 @@ function addTorrentEvents (torrent) {
|
|||||||
state.dock.badge += 1
|
state.dock.badge += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showDoneNotification(torrent)
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -571,3 +572,16 @@ function onError (err) {
|
|||||||
function onWarning (err) {
|
function onWarning (err) {
|
||||||
console.log('warning: %s', err.message)
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user