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

Commit

Permalink
Merge pull request #9318 from brave/ledger-balance-update
Browse files Browse the repository at this point in the history
fix ledger balance check enable/disable
  • Loading branch information
bsclifton committed Jun 14, 2017
2 parents 89058cf + 034b212 commit 915e13e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
9 changes: 9 additions & 0 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ const updateAboutDetails = (tab, tabValue) => {
const autofillAddresses = appState.getIn(['autofill', 'addresses'])
const versionInformation = appState.getIn(['about', 'brave', 'versionInformation'])
const aboutDetails = tabValue.get('aboutDetails')
// TODO(bridiver) - convert this to an action
if (url === 'about:preferences#payments') {
tab.on('destroyed', () => {
process.emit(messages.LEDGER_PAYMENTS_PRESENT, tabValue.get('tabId'), false)
})
process.emit(messages.LEDGER_PAYMENTS_PRESENT, tabValue.get('tabId'), true)
} else {
process.emit(messages.LEDGER_PAYMENTS_PRESENT, tabValue.get('tabId'), false)
}
if (location === 'about:preferences' || location === 'about:contributions' || location === aboutUrls.get('about:contributions')) {
const ledgerData = ledgerInfo.merge(publisherInfo).merge(preferencesData)
tab.send(messages.LEDGER_UPDATED, ledgerData.toJS())
Expand Down
10 changes: 9 additions & 1 deletion app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,16 @@ if (ipc) {
boot()
})

ipc.on(messages.LEDGER_PAYMENTS_PRESENT, (event, presentP) => {
let ledgerPaymentsPresent = {}
// TODO(bridiver) - convert this to an action
process.on(messages.LEDGER_PAYMENTS_PRESENT, (tabId, presentP) => {
if (presentP) {
ledgerPaymentsPresent[tabId] = presentP
} else {
delete ledgerPaymentsPresent[tabId]
}

if (Object.keys(ledgerPaymentsPresent).length > 0 && getSetting(settings.PAYMENTS_ENABLED)) {
if (!balanceTimeoutId) getBalance()
} else if (balanceTimeoutId) {
clearTimeout(balanceTimeoutId)
Expand Down
17 changes: 0 additions & 17 deletions app/renderer/components/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const shieldState = require('../../../common/state/shieldState')
const siteSettingsState = require('../../../common/state/siteSettingsState')
const menuBarState = require('../../../common/state/menuBarState')
const windowState = require('../../../common/state/windowState')
const windowStore = require('../../../../js/stores/windowStore')

// Util
const _ = require('underscore')
Expand Down Expand Up @@ -506,22 +505,6 @@ class Main extends ImmutableComponent {
self.resetAltMenuProcessing()
windowActions.onBlur(getCurrentWindowId())
}

windowStore.addChangeListener(function () {
const paymentsEnabled = getSetting(settings.PAYMENTS_ENABLED)
if (paymentsEnabled) {
const windowState = self.props.windowState
const tabs = windowState && windowState.get('tabs')
if (tabs) {
try {
const presentP = tabs.some((tab) => {
return tab.get('location') === 'about:preferences#payments'
})
ipc.send(messages.LEDGER_PAYMENTS_PRESENT, presentP)
} catch (ex) { }
}
}
})
}

checkForTitleMode () {
Expand Down

0 comments on commit 915e13e

Please sign in to comment.