diff --git a/app/browser/tabs.js b/app/browser/tabs.js index 9323810c26f..67ba51e63e1 100644 --- a/app/browser/tabs.js +++ b/app/browser/tabs.js @@ -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()) diff --git a/app/ledger.js b/app/ledger.js index d2b7a44dc20..1217cd24e2f 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -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) diff --git a/app/renderer/components/main/main.js b/app/renderer/components/main/main.js index 350c4accb90..cdbe739aaa1 100644 --- a/app/renderer/components/main/main.js +++ b/app/renderer/components/main/main.js @@ -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') @@ -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 () {