From 5820546dc446a2e823bca94f3acab3510753c527 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 3 Mar 2016 15:44:21 -0800 Subject: [PATCH] dock: only show progress when active torrents exist --- main/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main/index.js b/main/index.js index 8b42f8f3..1c65833b 100644 --- a/main/index.js +++ b/main/index.js @@ -86,21 +86,24 @@ function update () { updateDockIcon() } +setInterval(function () { + updateThrottled() +}, 1000) + function updateDockIcon () { if (state.view.client) { 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% - if (state.view.client.torrents.length === 0 || progress === 1) { + if (!activeTorrentsExist || progress === 1) { progress = -1 } electron.ipcRenderer.send('setProgress', progress) } } -setInterval(function () { - updateThrottled() -}, 1000) - function dispatch (action, ...args) { console.log('dispatch: %s %o', action, args) if (action === 'addTorrent') {