From 70dae5504271f9187395d94f58445a3c355f6cc0 Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Wed, 24 Apr 2019 15:47:14 -0400 Subject: [PATCH] Pass tweet metadata to SiteBanner --- .../brave_rewards/resources/donate/components/app.tsx | 7 ++----- .../resources/donate/components/donateToTwitterUser.tsx | 3 +++ .../resources/donate/components/siteBanner.tsx | 8 +++++++- components/brave_rewards/resources/donate/utils.ts | 4 ++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/components/brave_rewards/resources/donate/components/app.tsx b/components/brave_rewards/resources/donate/components/app.tsx index 7bbac671aa5f..3e0e800981cc 100644 --- a/components/brave_rewards/resources/donate/components/app.tsx +++ b/components/brave_rewards/resources/donate/components/app.tsx @@ -12,6 +12,7 @@ import DonateToTwitterUser from './donateToTwitterUser' // Utils import * as rewardsActions from '../actions/donate_actions' +import { isTwitterAccount } from '../utils' interface DonationDialogArgs { publisherKey: string @@ -28,10 +29,6 @@ export class App extends React.Component { return this.props.actions } - isTwitterAccount = (publisherKey: string) => { - return /^twitter#channel:[0-9]+$/.test(publisherKey) - } - render () { const { publishers } = this.props.rewardsDonateData @@ -47,7 +44,7 @@ export class App extends React.Component { } let donation - if (this.isTwitterAccount(publisherKey)) { + if (isTwitterAccount(publisherKey)) { const tweetMetaData = this.props.dialogArgs.tweetMetaData if (tweetMetaData) { donation = ( diff --git a/components/brave_rewards/resources/donate/components/donateToTwitterUser.tsx b/components/brave_rewards/resources/donate/components/donateToTwitterUser.tsx index e11ebb2358e2..d8df9c4727d1 100644 --- a/components/brave_rewards/resources/donate/components/donateToTwitterUser.tsx +++ b/components/brave_rewards/resources/donate/components/donateToTwitterUser.tsx @@ -34,6 +34,9 @@ class DonateToTwitterUser extends React.Component { 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 ( <> diff --git a/components/brave_rewards/resources/donate/components/siteBanner.tsx b/components/brave_rewards/resources/donate/components/siteBanner.tsx index d3743cef30b5..a31c9fe28dc3 100644 --- a/components/brave_rewards/resources/donate/components/siteBanner.tsx +++ b/components/brave_rewards/resources/donate/components/siteBanner.tsx @@ -160,7 +160,13 @@ class Banner extends React.Component { learnMoreNotice={'https://brave.com/faq-rewards/#unclaimed-funds'} addFundsLink={this.addFundsLink} > - {publisher.description} + { + utils.isTwitterAccount(publisher.publisherKey) + ?
+ {publisher.description} +
+ : publisher.description + } ) } diff --git a/components/brave_rewards/resources/donate/utils.ts b/components/brave_rewards/resources/donate/utils.ts index caf1153ca8ec..3ab3c9f3f06c 100644 --- a/components/brave_rewards/resources/donate/utils.ts +++ b/components/brave_rewards/resources/donate/utils.ts @@ -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) +}