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 #11693 from NejcZdovc/hotfix/#11639-empty
Browse files Browse the repository at this point in the history
Fixed empty modal on payments
  • Loading branch information
bsclifton committed Oct 31, 2017
1 parent 088a2b2 commit bafa261
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ const aboutTabUpdateListener = (tabId) => {
}
}

const isOnAboutLocation = (url, search) => {
if (url == null) {
return false
}

const path = url.split('?')
return Array.isArray(path) && path[0] === search
}

appStore.addChangeListener(debounce(aboutTabUpdateListener, 100))

ipcMain.on(messages.ABOUT_COMPONENT_INITIALIZED, (e) => {
Expand All @@ -145,7 +154,7 @@ ipcMain.on(messages.ABOUT_COMPONENT_INITIALIZED, (e) => {
const url = getSourceAboutUrl(tab.getURL())
const location = getBaseUrl(url)
if (location === 'about:preferences') {
if (url === 'about:preferences#payments') {
if (isOnAboutLocation(url, 'about:preferences#payments')) {
appActions.ledgerPaymentsPresent(tabId, true)
} else {
appActions.ledgerPaymentsPresent(tabId, false)
Expand All @@ -159,7 +168,8 @@ ipcMain.on(messages.ABOUT_COMPONENT_INITIALIZED, (e) => {
})
tab.on('did-navigate-in-page', (e, newUrl) => {
updateAboutDetails(tabId)
if (getSourceAboutUrl(newUrl) === 'about:preferences#payments') {
const url = getSourceAboutUrl(newUrl)
if (isOnAboutLocation(url, 'about:preferences#payments')) {
appActions.ledgerPaymentsPresent(tabId, true)
} else {
appActions.ledgerPaymentsPresent(tabId, false)
Expand Down Expand Up @@ -208,6 +218,7 @@ const updateAboutDetails = (tabId) => {
}

const location = getBaseUrl(url)
const onPaymentsPage = isOnAboutLocation(url, 'about:preferences#payments')

const appSettings = appState.get('settings')
const braveryDefaults = siteSettings.braveryDefaults(appState, appConfig)
Expand All @@ -219,7 +230,7 @@ const updateAboutDetails = (tabId) => {
sendAboutDetails(tabId, messages.BRAVERY_DEFAULTS_UPDATED, braveryDefaults)
sendAboutDetails(tabId, messages.SETTINGS_UPDATED, appSettings)
}
if (location === 'about:contributions' || url === 'about:preferences#payments') {
if (location === 'about:contributions' || onPaymentsPage) {
const ledgerInfo = ledgerState.getInfoProps(appState)
const preferencesData = appState.getIn(['about', 'preferences'], Immutable.Map())
const synopsis = appState.getIn(['ledger', 'about'])
Expand All @@ -231,7 +242,7 @@ const updateAboutDetails = (tabId) => {
.set('wizardData', wizardData)
.set('migration', migration)
sendAboutDetails(tabId, messages.LEDGER_UPDATED, ledgerData)
} else if (url === 'about:preferences#sync' || location === 'about:contributions' || url === 'about:preferences#payments') {
} else if (url === 'about:preferences#sync' || location === 'about:contributions' || onPaymentsPage) {
const sync = appState.get('sync', Immutable.Map())
sendAboutDetails(tabId, messages.SYNC_UPDATED, sync)
} else if (location === 'about:extensions' || url === 'about:preferences#extensions') {
Expand Down

0 comments on commit bafa261

Please sign in to comment.