dock: only show progress when active torrents exist

This commit is contained in:
Feross Aboukhadijeh
2016-03-03 15:44:21 -08:00
parent 8041e5faa3
commit 5820546dc4

View File

@@ -86,21 +86,24 @@ function update () {
updateDockIcon() updateDockIcon()
} }
setInterval(function () {
updateThrottled()
}, 1000)
function updateDockIcon () { function updateDockIcon () {
if (state.view.client) { if (state.view.client) {
var progress = state.view.client.progress var progress = state.view.client.progress
var activeTorrentsExist = state.view.client.torrents.some(function (torrent) {
return torrent.progress !== 1
})
// Hide progress bar when client has no torrents, or progress is 100% // Hide progress bar when client has no torrents, or progress is 100%
if (state.view.client.torrents.length === 0 || progress === 1) { if (!activeTorrentsExist || progress === 1) {
progress = -1 progress = -1
} }
electron.ipcRenderer.send('setProgress', progress) electron.ipcRenderer.send('setProgress', progress)
} }
} }
setInterval(function () {
updateThrottled()
}, 1000)
function dispatch (action, ...args) { function dispatch (action, ...args) {
console.log('dispatch: %s %o', action, args) console.log('dispatch: %s %o', action, args)
if (action === 'addTorrent') { if (action === 'addTorrent') {