Skip to content

Commit

Permalink
Merge pull request #1487 from brave/ac-update
Browse files Browse the repository at this point in the history
Updates settings page data when re-enabling rewards
  • Loading branch information
NejcZdovc committed Jan 29, 2019
2 parents 3ed6503 + 24196cf commit 0812863
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions components/brave_rewards/resources/ui/components/settingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ class SettingsPage extends React.Component<Props, {}> {
return this.props.actions
}

refreshActions () {
this.actions.getCurrentReport()
this.actions.getDonationTable()
this.actions.getContributeList()
this.actions.getPendingContributionsTotal()
this.actions.getReconcileStamp()
}

componentDidMount () {
if (this.props.rewardsData.firstLoad === null) {
// First load ever
Expand All @@ -47,14 +55,10 @@ class SettingsPage extends React.Component<Props, {}> {
this.actions.getWalletProperties()
}, 60000)

this.actions.getCurrentReport()
this.actions.getDonationTable()
this.actions.getContributeList()
this.refreshActions()
this.actions.getAdsData()
this.actions.checkImported()
this.actions.getReconcileStamp()
this.actions.getGrant()
this.actions.getPendingContributionsTotal()

// one time check (legacy fix)
// more info here https://github.com/brave/brave-browser/issues/2172
Expand All @@ -63,6 +67,23 @@ class SettingsPage extends React.Component<Props, {}> {
}
}

componentDidUpdate (prevProps: Props) {
if (
!prevProps.rewardsData.enabledMain &&
this.props.rewardsData.enabledMain
) {
this.refreshActions()
}

if (
!prevProps.rewardsData.enabledContribute &&
this.props.rewardsData.enabledContribute
) {
this.actions.getContributeList()
this.actions.getReconcileStamp()
}
}

componentWillUnmount () {
clearInterval(this.balanceTimerId)
}
Expand Down

0 comments on commit 0812863

Please sign in to comment.