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 #13973 from NejcZdovc/fix/#13972-server
Browse files Browse the repository at this point in the history
Adds server problem overlay
  • Loading branch information
Jason Sadler authored and NejcZdovc committed May 1, 2018
1 parent 47a615e commit cea9a88
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 4 deletions.
12 changes: 11 additions & 1 deletion app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,12 @@ const getPaymentInfo = (state) => {

client.getWalletProperties(amount, currency, function (err, body) {
if (err) {
console.error('getWalletProperties error: ' + err.toString())
if (err.message) {
console.error('getWalletProperties error: ' + err.message)
} else {
console.error('getWalletProperties error: ' + err.toString())
}
appActions.onWalletPropertiesError()
return
}

Expand Down Expand Up @@ -1824,6 +1829,11 @@ const setNewTimeUntilReconcile = (newReconcileTime = null) => {
}

const onWalletProperties = (state, body) => {
const currentStatus = ledgerState.getAboutProp(state, 'status')
if (currentStatus === ledgerStatuses.SERVER_PROBLEM) {
state = ledgerState.setAboutProp(state, 'status', '')
}

if (body == null) {
return state
}
Expand Down
6 changes: 6 additions & 0 deletions app/browser/reducers/ledgerReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const appConstants = require('../../../js/constants/appConstants')
const windowConstants = require('../../../js/constants/windowConstants')
const settings = require('../../../js/constants/settings')
const tabActionConstants = require('../../common/constants/tabAction')
const ledgerStatuses = require('../../common/constants/ledgerStatuses')

// State
const ledgerState = require('../../common/state/ledgerState')
Expand Down Expand Up @@ -522,6 +523,11 @@ const ledgerReducer = (state, action, immutableAction) => {
)
break
}
case appConstants.APP_ON_WALLET_PROPERTIES_ERROR:
{
state = ledgerState.setAboutProp(state, 'status', ledgerStatuses.SERVER_PROBLEM)
break
}
case appConstants.APP_ON_LEDGER_BACKUP_SUCCESS:
{
state = aboutPreferencesState.setBackupStatus(state, true)
Expand Down
3 changes: 2 additions & 1 deletion app/common/constants/ledgerStatuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

const statuses = {
CORRUPTED_SEED: 'corruptedSeed',
IN_PROGRESS: 'contributionInProgress'
IN_PROGRESS: 'contributionInProgress',
SERVER_PROBLEM: 'serverProblem'
}

module.exports = statuses
3 changes: 3 additions & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ lastPass=LastPass®
ledgerBackupText1=Below, you will find the anonymized recovery key that is required if you ever lose access to this computer.
ledgerBackupText2=Make sure you keep this key private, or else your wallet will be compromised.
ledgerBackupTitle=Backup your Brave wallet
ledgerNetworkErrorMessage=The Brave Payments server is not responding. We will fix this as soon as possible.
ledgerNetworkErrorTitle=Uh oh.
ledgerNetworkErrorText=Note: This error could also be caused by a network connection problem.
ledgerPaymentsShown=Brave Payments
ledgerRecoveryContent=Note: The recovered BAT wallet will replace the current BAT wallet, which will be discarded.
ledgerRecoveryFailedMessage=Please re-enter keys or try different keys.
Expand Down
5 changes: 4 additions & 1 deletion app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ var rendererIdentifiers = function () {
'promotionClaimedErrorTitle',
'corruptedOverlayTitle',
'corruptedOverlayMessage',
'corruptedOverlayText'
'corruptedOverlayText',
'ledgerNetworkErrorTitle',
'ledgerNetworkErrorMessage',
'ledgerNetworkErrorText'
].concat(countryCodes).concat(availableLanguages)
}

Expand Down
9 changes: 9 additions & 0 deletions app/renderer/components/preferences/payment/enabledContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ class EnabledContent extends ImmutableComponent {
/>
break
}

case ledgerStatuses.SERVER_PROBLEM:
{
showClose = false
title = locale.translation('ledgerNetworkErrorTitle')
message = locale.translation('ledgerNetworkErrorMessage')
text = locale.translation('ledgerNetworkErrorText')
break
}
default:
{
return
Expand Down
6 changes: 6 additions & 0 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1976,6 +1976,12 @@ const appActions = {
})
},

onWalletPropertiesError: function () {
dispatch({
actionType: appConstants.APP_ON_WALLET_PROPERTIES_ERROR
})
},

onPublisherToggleUpdate: function () {
dispatch({
actionType: appConstants.APP_ON_PUBLISHER_TOGGLE_UPDATE
Expand Down
1 change: 1 addition & 0 deletions js/constants/appConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ const appConstants = {
APP_ON_LEDGER_MEDIA_PUBLISHER: _,
APP_ON_LEDGER_BACKUP_SUCCESS: _,
APP_ADD_PUBLISHER_TO_LEDGER: _,
APP_ON_WALLET_PROPERTIES_ERROR: _,
APP_ON_PUBLISHER_TOGGLE_UPDATE: _
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/app/browser/api/ledgerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ describe('ledger api unit tests', function () {
})

it('null case', function () {
ledgerApi.onWalletProperties()
ledgerApi.onWalletProperties(state)
assert(generatePaymentDataSpy.notCalled)
})

Expand Down

0 comments on commit cea9a88

Please sign in to comment.