Skip to content

Commit

Permalink
Merge pull request #2505 from brave/empty-tweet
Browse files Browse the repository at this point in the history
Displays default text with correct title for an empty tweet
  • Loading branch information
NejcZdovc authored May 27, 2019
2 parents 8f07fc0 + 8532186 commit 737cad0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions browser/ui/webui/brave_webui_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
16 changes: 15 additions & 1 deletion components/brave_rewards/resources/tip/components/siteBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ class Banner extends React.Component<Props, State> {
return 'chrome://rewards/#add-funds'
}

getTweetText () {
if (!this.props.tweetMetaData ||
!this.props.tweetMetaData.tweetText ||
this.props.tweetMetaData.tweetText.length === 0) {
return null
}

return (
<TweetBox
tweetText={this.props.tweetMetaData.tweetText}
tweetTimestamp={this.props.tweetMetaData.tweetTimestamp}
/>)
}

render () {
const { walletInfo } = this.props.rewardsDonateData
const { balance } = walletInfo
Expand Down Expand Up @@ -173,7 +187,7 @@ class Banner extends React.Component<Props, State> {
>
{
this.props.tweetMetaData
? <TweetBox tweetText={this.props.tweetMetaData.tweetText} tweetTimestamp={this.props.tweetMetaData.tweetTimestamp} />
? this.getTweetText()
: publisher.description
}
</SiteBanner>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ class TipTwitterUser extends React.Component<Props, {}> {

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 (
<>
Expand Down
1 change: 1 addition & 0 deletions components/resources/brave_components_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@
<message name="IDS_BRAVE_UI_TURN_ON_REWARDS_TITLE" desc="">Activate Rewards</message>
<message name="IDS_BRAVE_UI_TWEET_NOW" desc="">Tweet</message>
<message name="IDS_BRAVE_UI_TWEET_TIP_TITLE" desc="">Tip @{{ user }} for their tweet:</message>
<message name="IDS_BRAVE_UI_TWEET_TIP_TITLE_EMPTY" desc="We use this title when twitter text is empty">Tip @{{ user }} for their tweet!</message>
<message name="IDS_BRAVE_UI_TYPE" desc="">Type</message>
<message name="IDS_BRAVE_UI_VERIFIED_PUBLISHER" desc="">Brave Verified Publisher</message>
<message name="IDS_BRAVE_UI_VIEW_MONTHLY" desc="">View Monthly Statement for Details</message>
Expand Down

0 comments on commit 737cad0

Please sign in to comment.