Skip to content

Commit 65c6ff2

Browse files
committedOct 24, 2018
Adds waiter to rewards panel
Resolves brave/brave-browser#1502
1 parent c59a4ae commit 65c6ff2

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed
 

‎components/brave_rewards/extension/brave_rewards/_locales/en/messages.json

+4
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,9 @@
184184
"grantNotification": {
185185
"message": "You have a grant waiting for you.",
186186
"description": ""
187+
},
188+
"braveRewardsCreatingText": {
189+
"message": "Creating wallet",
190+
"description": ""
187191
}
188192
}

‎components/brave_rewards/extension/brave_rewards/components/app.tsx

+30-5
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ interface Props extends RewardsExtension.ComponentProps {
1818

1919
interface State {
2020
windowId: number
21+
creating: boolean
2122
}
2223

2324
export class RewardsPanel extends React.Component<Props, State> {
2425
constructor (props: Props) {
2526
super(props)
2627
this.state = {
27-
windowId: -1
28+
windowId: -1,
29+
creating: false
2830
}
2931
}
3032

@@ -39,6 +41,16 @@ export class RewardsPanel extends React.Component<Props, State> {
3941
) {
4042
this.getTabData()
4143
}
44+
45+
if (
46+
this.state.creating &&
47+
!prevProps.rewardsPanelData.walletCreateFailed &&
48+
this.props.rewardsPanelData.walletCreateFailed
49+
) {
50+
this.setState({
51+
creating: false
52+
})
53+
}
4254
}
4355

4456
getTabData () {
@@ -69,17 +81,30 @@ export class RewardsPanel extends React.Component<Props, State> {
6981
})
7082
}
7183

84+
get actions () {
85+
return this.props.actions
86+
}
87+
88+
onCreate = () => {
89+
this.setState({
90+
creating: true
91+
})
92+
this.actions.createWallet()
93+
}
94+
7295
render () {
73-
const { rewardsPanelData, actions } = this.props
96+
const { walletCreateFailed, walletCreated } = this.props.rewardsPanelData
7497

7598
return (
7699
<>
77100
{
78-
!rewardsPanelData.walletCreated
101+
!walletCreated
79102
? <PanelWelcome
103+
error={walletCreateFailed}
104+
creating={this.state.creating}
80105
variant={'two'}
81-
optInAction={actions.createWallet}
82-
optInErrorAction={actions.createWallet}
106+
optInAction={this.onCreate}
107+
optInErrorAction={this.onCreate}
83108
moreLink={this.openRewards}
84109
/>
85110
: <Panel windowId={this.state.windowId} />

0 commit comments

Comments
 (0)
Please sign in to comment.