From 8532186891d7d98850cdf4c9b6d46199f92b6d73 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Mon, 27 May 2019 17:38:49 +0200 Subject: [PATCH] Displayes default text with correct title for an empty tweet Resolves https://github.com/brave/brave-browser/issues/4583 --- browser/ui/webui/brave_webui_source.cc | 1 + .../resources/tip/components/siteBanner.tsx | 16 +++++++++++++++- .../resources/tip/components/tipTwitterUser.tsx | 8 +++++++- .../resources/brave_components_strings.grd | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/browser/ui/webui/brave_webui_source.cc b/browser/ui/webui/brave_webui_source.cc index 1eb2ccf5834c..a187ba948046 100644 --- a/browser/ui/webui/brave_webui_source.cc +++ b/browser/ui/webui/brave_webui_source.cc @@ -576,6 +576,7 @@ void CustomizeWebUIHTMLSource(const std::string &name, { "tokens", IDS_BRAVE_UI_TOKENS }, { "tweetNow", IDS_BRAVE_UI_TWEET_NOW }, { "tweetTipTitle", IDS_BRAVE_UI_TWEET_TIP_TITLE }, + { "tweetTipTitleEmpty", IDS_BRAVE_UI_TWEET_TIP_TITLE_EMPTY }, { "unVerifiedTextMore", IDS_BRAVE_UI_SITE_UNVERIFIED_TEXT_MORE }, { "walletBalance", IDS_BRAVE_UI_WALLET_BALANCE }, { "welcome", IDS_BRAVE_UI_WELCOME }, diff --git a/components/brave_rewards/resources/tip/components/siteBanner.tsx b/components/brave_rewards/resources/tip/components/siteBanner.tsx index 8af9d3aac690..97bd6d80cb62 100644 --- a/components/brave_rewards/resources/tip/components/siteBanner.tsx +++ b/components/brave_rewards/resources/tip/components/siteBanner.tsx @@ -131,6 +131,20 @@ class Banner extends React.Component { return 'chrome://rewards/#add-funds' } + getTweetText () { + if (!this.props.tweetMetaData || + !this.props.tweetMetaData.tweetText || + this.props.tweetMetaData.tweetText.length === 0) { + return null + } + + return ( + ) + } + render () { const { walletInfo } = this.props.rewardsDonateData const { balance } = walletInfo @@ -173,7 +187,7 @@ class Banner extends React.Component { > { this.props.tweetMetaData - ? + ? this.getTweetText() : publisher.description } diff --git a/components/brave_rewards/resources/tip/components/tipTwitterUser.tsx b/components/brave_rewards/resources/tip/components/tipTwitterUser.tsx index 3f1117dea3e8..f9d622364041 100644 --- a/components/brave_rewards/resources/tip/components/tipTwitterUser.tsx +++ b/components/brave_rewards/resources/tip/components/tipTwitterUser.tsx @@ -37,7 +37,13 @@ class TipTwitterUser extends React.Component { const publisher = this.props.publisher const tweetMetaData = this.props.tweetMetaData - publisher.title = getLocale('tweetTipTitle', { user: tweetMetaData.screenName }) + const key = + tweetMetaData && + tweetMetaData.tweetText && + tweetMetaData.tweetText.length > 0 + ? 'tweetTipTitle' + : 'tweetTipTitleEmpty' + publisher.title = getLocale(key, { user: tweetMetaData.screenName }) return ( <> diff --git a/components/resources/brave_components_strings.grd b/components/resources/brave_components_strings.grd index 748a1dc83e30..89f88772f2a9 100644 --- a/components/resources/brave_components_strings.grd +++ b/components/resources/brave_components_strings.grd @@ -478,6 +478,7 @@ Activate Rewards Tweet Tip @{{ user }} for their tweet: + Tip @{{ user }} for their tweet! Type Brave Verified Publisher View Monthly Statement for Details