Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Sadler committed May 29, 2019
1 parent f6956d1 commit f744da6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"description": "The whole string is 'Enable tips on YouTube for like.'"
},
"verifiedPublisher": {
"message": "Brave Verified Publisher",
"description": "Tells user that this particular publisher is verified publisher"
"message": "Brave Verified Creator",
"description": "Tells user that this particular publisher is a Brave Verified Creator"
},
"rewardsContributeAttentionScore": {
"message": "Attention",
Expand Down Expand Up @@ -298,7 +298,7 @@
"description": "Error title when user missed a grant."
},
"unVerifiedCheck": {
"message": "Check Again...",
"message": "Refresh Status",
"description": "Text of link that allows to check verified status of unverified publisher"
},
"unVerifiedPublisher": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ interface State {
publisherKey: string | null
refreshingPublisher: boolean
publisherRefreshed: boolean
timerPassed: boolean
}

export class Panel extends React.Component<Props, State> {
private defaultTipAmounts: number[]

private delayTimer: ReturnType<typeof setTimeout>
constructor (props: Props) {
super(props)
this.state = {
showSummary: true,
publisherKey: null,
refreshingPublisher: false,
publisherRefreshed: false
publisherRefreshed: false,
timerPassed: false
}
this.defaultTipAmounts = [1, 5, 10]
}
Expand Down Expand Up @@ -85,6 +87,10 @@ export class Panel extends React.Component<Props, State> {
}
}

componentWillUnmount () {
clearTimeout(this.delayTimer)
}

get gradientColor () {
return this.state.showSummary ? '233,235,255' : '249,251,252'
}
Expand Down Expand Up @@ -414,21 +420,41 @@ export class Panel extends React.Component<Props, State> {
return defaultContribution
}

initiateDelayCounter = () => {
clearTimeout(this.delayTimer)
this.delayTimer = setTimeout(() => {
this.setState({
timerPassed: true
})
}, 2000)
}

resetPublisherStatus = () => {
if (!this.state.timerPassed) {
setTimeout(this.resetPublisherStatus, 250)
} else {
this.setState({
timerPassed: false,
refreshingPublisher: false,
publisherRefreshed: true
})
}
}

refreshPublisher = () => {
this.setState({
refreshingPublisher: true
refreshingPublisher: true,
timerPassed: false
})
this.initiateDelayCounter()
const publisher: RewardsExtension.Publisher | undefined = this.getPublisher()
const publisherKey = publisher && publisher.publisher_key
if (publisherKey) {
chrome.braveRewards.refreshPublisher(publisherKey, (verified: boolean, publisherKey: string) => {
if (publisherKey) {
this.actions.refreshPublisher(verified, publisherKey)
}
this.setState({
refreshingPublisher: false,
publisherRefreshed: true
})
this.resetPublisherStatus()
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
"@types/react-redux": "6.0.4",
"@types/redux-logger": "^3.0.7",
"awesome-typescript-loader": "^5.2.1",
"brave-ui": "github:brave/brave-ui#271e4e8a17428f66d22737fbe465b4600ad14c78",
"brave-ui": "github:brave/brave-ui#cedd99a936c6a6c2e28d4a21dbdcc9324e797d68",
"css-loader": "^2.1.1",
"csstype": "^2.5.5",
"deep-freeze-node": "^1.1.3",
Expand Down

0 comments on commit f744da6

Please sign in to comment.