Skip to content

Commit

Permalink
Pass tweet metadata to SiteBanner
Browse files Browse the repository at this point in the history
  • Loading branch information
emerick committed Apr 26, 2019
1 parent 076936a commit 70dae55
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
7 changes: 2 additions & 5 deletions components/brave_rewards/resources/donate/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import DonateToTwitterUser from './donateToTwitterUser'

// Utils
import * as rewardsActions from '../actions/donate_actions'
import { isTwitterAccount } from '../utils'

interface DonationDialogArgs {
publisherKey: string
Expand All @@ -28,10 +29,6 @@ export class App extends React.Component<Props, {}> {
return this.props.actions
}

isTwitterAccount = (publisherKey: string) => {
return /^twitter#channel:[0-9]+$/.test(publisherKey)
}

render () {
const { publishers } = this.props.rewardsDonateData

Expand All @@ -47,7 +44,7 @@ export class App extends React.Component<Props, {}> {
}

let donation
if (this.isTwitterAccount(publisherKey)) {
if (isTwitterAccount(publisherKey)) {
const tweetMetaData = this.props.dialogArgs.tweetMetaData
if (tweetMetaData) {
donation = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class DonateToTwitterUser extends React.Component<Props, {}> {
const { finished, error } = this.props.rewardsDonateData

const publisher = this.props.publisher
const tweetMetaData = this.props.tweetMetaData
publisher.title = getLocale('tweetTipTitle', { user: tweetMetaData.screenName })
publisher.description = tweetMetaData.tweetText

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ class Banner extends React.Component<Props, State> {
learnMoreNotice={'https://brave.com/faq-rewards/#unclaimed-funds'}
addFundsLink={this.addFundsLink}
>
{publisher.description}
{
utils.isTwitterAccount(publisher.publisherKey)
? <div style={{ border: '1px solid #d3d3d3', borderRadius: '5px', margin: '20px 0 0 0', padding: '20px' }}>
{publisher.description}
</div>
: publisher.description
}
</SiteBanner>
)
}
Expand Down
4 changes: 4 additions & 0 deletions components/brave_rewards/resources/donate/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ export const convertProbiToFixed = (probi: string, places: number = 1) => {

return result
}

export const isTwitterAccount = (publisherKey: string) => {
return /^twitter#channel:[0-9]+$/.test(publisherKey)
}

0 comments on commit 70dae55

Please sign in to comment.