Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displays default text with correct title for an empty tweet #2505

Merged
merged 1 commit into from
May 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Displayes default text with correct title for an empty tweet
NejcZdovc committed May 27, 2019

Verified

This commit was signed with the committer’s verified signature. The key has expired.
NejcZdovc Nejc Zdovc
commit 8532186891d7d98850cdf4c9b6d46199f92b6d73
1 change: 1 addition & 0 deletions browser/ui/webui/brave_webui_source.cc
Original file line number Diff line number Diff line change
@@ -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 },
Original file line number Diff line number Diff line change
@@ -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
@@ -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>
Original file line number Diff line number Diff line change
@@ -37,7 +37,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 (
<>
1 change: 1 addition & 0 deletions components/resources/brave_components_strings.grd
Original file line number Diff line number Diff line change
@@ -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>