Skip to content

Commit

Permalink
Adds waiter to rewards panel
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Oct 24, 2018
1 parent c59a4ae commit 65c6ff2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,9 @@
"grantNotification": {
"message": "You have a grant waiting for you.",
"description": ""
},
"braveRewardsCreatingText": {
"message": "Creating wallet",
"description": ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ interface Props extends RewardsExtension.ComponentProps {

interface State {
windowId: number
creating: boolean
}

export class RewardsPanel extends React.Component<Props, State> {
constructor (props: Props) {
super(props)
this.state = {
windowId: -1
windowId: -1,
creating: false
}
}

Expand All @@ -39,6 +41,16 @@ export class RewardsPanel extends React.Component<Props, State> {
) {
this.getTabData()
}

if (
this.state.creating &&
!prevProps.rewardsPanelData.walletCreateFailed &&
this.props.rewardsPanelData.walletCreateFailed
) {
this.setState({
creating: false
})
}
}

getTabData () {
Expand Down Expand Up @@ -69,17 +81,30 @@ export class RewardsPanel extends React.Component<Props, State> {
})
}

get actions () {
return this.props.actions
}

onCreate = () => {
this.setState({
creating: true
})
this.actions.createWallet()
}

render () {
const { rewardsPanelData, actions } = this.props
const { walletCreateFailed, walletCreated } = this.props.rewardsPanelData

return (
<>
{
!rewardsPanelData.walletCreated
!walletCreated
? <PanelWelcome
error={walletCreateFailed}
creating={this.state.creating}
variant={'two'}
optInAction={actions.createWallet}
optInErrorAction={actions.createWallet}
optInAction={this.onCreate}
optInErrorAction={this.onCreate}
moreLink={this.openRewards}
/>
: <Panel windowId={this.state.windowId} />
Expand Down

0 comments on commit 65c6ff2

Please sign in to comment.