Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Small tweaks:
Browse files Browse the repository at this point in the history
- only perform check if payments are enabled
- check using Array.prototype.some (which returns on first truthy result)

Auditors: @mrose17
  • Loading branch information
bsclifton committed Nov 30, 2016
1 parent 9c33676 commit e67f6f8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions js/components/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,22 @@ class Tab extends ImmutableComponent {
}
}

windowStore.addChangeListener(() => {
var presentP = false
const windowState = windowStore.getState().toJS()

windowState.tabs.forEach((tab) => { if (tab.location === 'about:preferences#payments') presentP = true })
const paymentsEnabled = () => {
const getSetting = require('../settings').getSetting
const settings = require('../constants/settings')
return getSetting(settings.PAYMENTS_ENABLED)
}

ipc.send(messages.LEDGER_PAYMENTS_PRESENT, presentP)
windowStore.addChangeListener(() => {
if (paymentsEnabled()) {
const windowState = windowStore.getState()
const tabs = windowState && windowState.get('tabs')
if (tabs) {
const presentP = tabs.some((tab) => {
return tab.get('location') === 'about:preferences#payments'
})
ipc.send(messages.LEDGER_PAYMENTS_PRESENT, presentP)
}
}
})
module.exports = Tab

1 comment on commit e67f6f8

@mrose17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsclifton - i think this is fine. why not merge this PR so a UI developer can look at the second half of resolving #4720

thanks!

Please sign in to comment.