From 65c6ff2011fdd74826a27e00ef29223b1bf85ab8 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Wed, 24 Oct 2018 10:45:12 +0200 Subject: [PATCH] Adds waiter to rewards panel Resolves https://github.com/brave/brave-browser/issues/1502 --- .../brave_rewards/_locales/en/messages.json | 4 +++ .../brave_rewards/components/app.tsx | 35 ++++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/components/brave_rewards/extension/brave_rewards/_locales/en/messages.json b/components/brave_rewards/extension/brave_rewards/_locales/en/messages.json index 0796f4b66643..f7b0b16134ef 100644 --- a/components/brave_rewards/extension/brave_rewards/_locales/en/messages.json +++ b/components/brave_rewards/extension/brave_rewards/_locales/en/messages.json @@ -184,5 +184,9 @@ "grantNotification": { "message": "You have a grant waiting for you.", "description": "" + }, + "braveRewardsCreatingText": { + "message": "Creating wallet", + "description": "" } } diff --git a/components/brave_rewards/extension/brave_rewards/components/app.tsx b/components/brave_rewards/extension/brave_rewards/components/app.tsx index 275f701aa4d2..174c2e9867da 100644 --- a/components/brave_rewards/extension/brave_rewards/components/app.tsx +++ b/components/brave_rewards/extension/brave_rewards/components/app.tsx @@ -18,13 +18,15 @@ interface Props extends RewardsExtension.ComponentProps { interface State { windowId: number + creating: boolean } export class RewardsPanel extends React.Component { constructor (props: Props) { super(props) this.state = { - windowId: -1 + windowId: -1, + creating: false } } @@ -39,6 +41,16 @@ export class RewardsPanel extends React.Component { ) { this.getTabData() } + + if ( + this.state.creating && + !prevProps.rewardsPanelData.walletCreateFailed && + this.props.rewardsPanelData.walletCreateFailed + ) { + this.setState({ + creating: false + }) + } } getTabData () { @@ -69,17 +81,30 @@ export class RewardsPanel extends React.Component { }) } + 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 ? :