From b2525e559dc9ae2d77f682dd18771ac98787c9b6 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Fri, 21 Dec 2018 12:58:51 +0100 Subject: [PATCH] Legacy fix for wrong addresses Resolves https://github.com/brave/brave-browser/issues/2172 --- .../resources/ui/actions/rewards_actions.ts | 2 ++ .../resources/ui/components/settingsPage.tsx | 6 ++++++ .../resources/ui/reducers/wallet_reducer.ts | 14 ++++++++++++++ components/brave_rewards/resources/ui/storage.ts | 1 + components/definitions/rewards.d.ts | 1 + 5 files changed, 24 insertions(+) diff --git a/components/brave_rewards/resources/ui/actions/rewards_actions.ts b/components/brave_rewards/resources/ui/actions/rewards_actions.ts index 8cd14cd7d94e..b9548e490061 100644 --- a/components/brave_rewards/resources/ui/actions/rewards_actions.ts +++ b/components/brave_rewards/resources/ui/actions/rewards_actions.ts @@ -151,3 +151,5 @@ export const onAdsSettingSave = (key: string, value: any) => action(types.ON_ADS key, value }) + +export const getAddresses = () => action(types.GET_ADDRESSES) diff --git a/components/brave_rewards/resources/ui/components/settingsPage.tsx b/components/brave_rewards/resources/ui/components/settingsPage.tsx index 16f767d56417..37dcce95dcb2 100644 --- a/components/brave_rewards/resources/ui/components/settingsPage.tsx +++ b/components/brave_rewards/resources/ui/components/settingsPage.tsx @@ -53,6 +53,12 @@ class SettingsPage extends React.Component { this.actions.checkImported() this.actions.getAdsData() this.actions.getCurrentReport() + + // one time check (legacy fix) + // more info here https://github.com/brave/brave-browser/issues/2172 + if (!this.props.rewardsData.ui.addressCheck) { + this.actions.getAddresses() + } } componentWillUnmount () { diff --git a/components/brave_rewards/resources/ui/reducers/wallet_reducer.ts b/components/brave_rewards/resources/ui/reducers/wallet_reducer.ts index 872f45f5c04f..e1653962e59c 100644 --- a/components/brave_rewards/resources/ui/reducers/wallet_reducer.ts +++ b/components/brave_rewards/resources/ui/reducers/wallet_reducer.ts @@ -202,6 +202,20 @@ const walletReducer: Reducer = (state: Rewards.State, state.contributionMonthly = action.payload.amount break } + case types.GET_ADDRESSES: + { + state = { ...state } + let ui = state.ui + ui.addressCheck = true + + chrome.send('brave_rewards.getAddresses') + + state = { + ...state, + ui + } + + } } return state diff --git a/components/brave_rewards/resources/ui/storage.ts b/components/brave_rewards/resources/ui/storage.ts index 1cb9eee68f9c..fea02f231271 100644 --- a/components/brave_rewards/resources/ui/storage.ts +++ b/components/brave_rewards/resources/ui/storage.ts @@ -32,6 +32,7 @@ export const defaultState: Rewards.State = { recoveryKey: '', reconcileStamp: 0, ui: { + addressCheck: false, emptyWallet: true, modalBackup: false, walletCorrupted: false, diff --git a/components/definitions/rewards.d.ts b/components/definitions/rewards.d.ts index bd4945b2aa6f..859b7e13c1e2 100644 --- a/components/definitions/rewards.d.ts +++ b/components/definitions/rewards.d.ts @@ -52,6 +52,7 @@ declare namespace Rewards { tipsList: Publisher[] tipsLoad: boolean ui: { + addressCheck: boolean emptyWallet: boolean modalBackup: boolean walletRecoverySuccess: boolean | null