Skip to content

Commit

Permalink
fix(browserAction): hide quick upload when no peers
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed May 6, 2017
1 parent 1837cee commit 3b7cde7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions add-on/src/popup/browser-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ async function updatePopup () {
const peerCount = await background.getSwarmPeerCount()
set('swarm-peers-val', peerCount < 0 ? offline : peerCount)
ipfsIcon.src = peerCount > 0 ? ipfsIconOn : ipfsIconOff
if (peerCount > 0) {
if (peerCount > 0) { // API is online & there are peers
show('quick-upload')
} else {
hide('quick-upload')
if (peerCount < 0) {
hide('open-webui')
}
}
if (peerCount < 0) { // API is offline
hide('open-webui')
} else {
show('open-webui')
}
} catch (error) {
console.error(`Unable update peer count due to ${error}`)
Expand All @@ -107,6 +109,8 @@ async function updatePopup () {
}

// run on initial popup load
hide('quick-upload')
hide('open-webui')
updatePopup()

// listen to any changes and update diagnostics
Expand Down

0 comments on commit 3b7cde7

Please sign in to comment.