From 12342c90b51af7aa202c6d49b0c9f651d3af0e38 Mon Sep 17 00:00:00 2001 From: ryanml Date: Tue, 18 Dec 2018 04:08:54 -0700 Subject: [PATCH] Fixes brave-browser/issues#2273 Fixes brave-browser/issues#2332 Triggers balance report fetch onWalletProperties, this is so that reports update along with wallet info Also ensures that the current report is fetched on settings mount --- components/brave_rewards/browser/rewards_service_impl.cc | 2 ++ .../brave_rewards/resources/ui/actions/rewards_actions.ts | 2 ++ .../brave_rewards/resources/ui/components/settingsPage.tsx | 1 + .../brave_rewards/resources/ui/constants/rewards_types.ts | 3 ++- .../brave_rewards/resources/ui/reducers/wallet_reducer.ts | 5 +++++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/components/brave_rewards/browser/rewards_service_impl.cc b/components/brave_rewards/browser/rewards_service_impl.cc index 949b64fb18d5..00104b13bd01 100644 --- a/components/brave_rewards/browser/rewards_service_impl.cc +++ b/components/brave_rewards/browser/rewards_service_impl.cc @@ -606,6 +606,7 @@ void RewardsServiceImpl::OnGrantFinish(ledger::Result result, grant.probi); } + GetCurrentBalanceReport(); TriggerOnGrantFinish(result, grant); } @@ -624,6 +625,7 @@ void RewardsServiceImpl::OnReconcileComplete(ledger::Result result, GetCurrentTimestamp()); } + GetCurrentBalanceReport(); for (auto& observer : observers_) observer.OnReconcileComplete(this, result, diff --git a/components/brave_rewards/resources/ui/actions/rewards_actions.ts b/components/brave_rewards/resources/ui/actions/rewards_actions.ts index 143e241c512c..8cd14cd7d94e 100644 --- a/components/brave_rewards/resources/ui/actions/rewards_actions.ts +++ b/components/brave_rewards/resources/ui/actions/rewards_actions.ts @@ -93,6 +93,8 @@ export const onBalanceReports = (reports: Record) => act reports }) +export const getCurrentReport = () => action(types.GET_CURRENT_REPORT, {}) + export const excludePublisher = (publisherKey: string) => action(types.ON_EXCLUDE_PUBLISHER, { publisherKey }) diff --git a/components/brave_rewards/resources/ui/components/settingsPage.tsx b/components/brave_rewards/resources/ui/components/settingsPage.tsx index 3e33869862c8..16f767d56417 100644 --- a/components/brave_rewards/resources/ui/components/settingsPage.tsx +++ b/components/brave_rewards/resources/ui/components/settingsPage.tsx @@ -52,6 +52,7 @@ class SettingsPage extends React.Component { this.actions.getContributeList() this.actions.checkImported() this.actions.getAdsData() + this.actions.getCurrentReport() } componentWillUnmount () { diff --git a/components/brave_rewards/resources/ui/constants/rewards_types.ts b/components/brave_rewards/resources/ui/constants/rewards_types.ts index c01a50e559c9..c6f45f1d1107 100644 --- a/components/brave_rewards/resources/ui/constants/rewards_types.ts +++ b/components/brave_rewards/resources/ui/constants/rewards_types.ts @@ -46,5 +46,6 @@ export const enum types { ON_IMPORTED_CHECK = '@@rewards/ON_IMPORTED_CHECK', GET_ADS_DATA = '@@rewards/GET_ADS_DATA', ON_ADS_DATA = '@@rewards/ON_ADS_DATA', - ON_ADS_SETTING_SAVE = '@@rewards/ON_ADS_SETTING_SAVE' + ON_ADS_SETTING_SAVE = '@@rewards/ON_ADS_SETTING_SAVE', + GET_CURRENT_REPORT = '@@rewards/GET_CURRENT_REPORT' } diff --git a/components/brave_rewards/resources/ui/reducers/wallet_reducer.ts b/components/brave_rewards/resources/ui/reducers/wallet_reducer.ts index 3592c021dd5d..872f45f5c04f 100644 --- a/components/brave_rewards/resources/ui/reducers/wallet_reducer.ts +++ b/components/brave_rewards/resources/ui/reducers/wallet_reducer.ts @@ -170,6 +170,11 @@ const walletReducer: Reducer = (state: Rewards.State, } break } + case types.GET_CURRENT_REPORT: + { + chrome.send('brave_rewards.getBalanceReports') + break + } case types.ON_BALANCE_REPORTS: { state = { ...state }