Skip to content

Commit

Permalink
Add provider to tip compliment
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkuki committed May 30, 2019
1 parent 8ad632b commit a07fe59
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
7 changes: 5 additions & 2 deletions browser/ui/webui/brave_tip_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void RewardsTipDOMHandler::OnRecurringTipSaved(
}

void RewardsTipDOMHandler::TweetTip(const base::ListValue *args) {
DCHECK_EQ(args->GetSize(), 2U);
DCHECK_EQ(args->GetSize(), 3U);

if (!rewards_service_)
return;
Expand All @@ -359,10 +359,13 @@ void RewardsTipDOMHandler::TweetTip(const base::ListValue *args) {
std::string tweet_id;
if (!args->GetString(1, &tweet_id))
return;
std::string provider;
if (!args->GetString(2, &provider))
return;

// Share the tip comment/compliment on Twitter.
std::string comment = l10n_util::GetStringFUTF8(
IDS_BRAVE_REWARDS_LOCAL_COMPLIMENT_TWEET, base::UTF8ToUTF16(name));
IDS_BRAVE_REWARDS_LOCAL_COMPLIMENT_TWEET, base::UTF8ToUTF16(name), base::UTF8ToUTF16(provider));
std::string hashtag = l10n_util::GetStringUTF8(
IDS_BRAVE_REWARDS_LOCAL_COMPLIMENT_TWEET_HASHTAG);
std::map<std::string, std::string> share_url_args;
Expand Down
5 changes: 3 additions & 2 deletions components/brave_rewards/resources/tip/actions/tip_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { types } from '../constants/tip_types'

export const onCloseDialog = () => action(types.ON_CLOSE_DIALOG)

export const onTweet = (name: string, tweetId: string) => action(types.ON_TWEET, {
export const onTweet = (name: string, tweetId: string, provider: string) => action(types.ON_TWEET, {
name,
tweetId
tweetId,
provider
})

export const onPublisherBanner = (data: RewardsTip.Publisher) => action(types.ON_PUBLISHER_BANNER, {
Expand Down
6 changes: 3 additions & 3 deletions components/brave_rewards/resources/tip/components/tipSite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class TipSite extends React.Component<Props, {}> {

onTweet = () => {
let name = this.props.publisher.name
if (this.props.publisher.provider === 'twitter') {
let provider = this.props.publisher.provider
if (provider === 'twitter') {
const url = this.props.url
if (url && url.length > 0) {
name = `@${url.replace(/^.*\/(.*)$/, '$1')}`
}
}

this.actions.onTweet(name, '')
this.actions.onTweet(name, '', provider)
this.actions.onCloseDialog()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const defaultState: RewardsTip.State = {

const publishersReducer: Reducer<RewardsTip.State> = (state: RewardsTip.State = defaultState, action) => {
const payload = action.payload

switch (action.type) {
case types.ON_CLOSE_DIALOG:
state = { ...state }
Expand All @@ -34,7 +33,8 @@ const publishersReducer: Reducer<RewardsTip.State> = (state: RewardsTip.State =
case types.ON_TWEET:
chrome.send('brave_rewards_tip.tweetTip', [
payload.name,
payload.tweetId
payload.tweetId,
payload.provider
])
break
case types.ON_PUBLISHER_BANNER: {
Expand Down
2 changes: 1 addition & 1 deletion components/resources/brave_components_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
<message name="IDS_BRAVE_REWARDS_LOCAL_GRANT_ALREADY_CLAIMED_TEXT" desc="">Sorry, it appears that this grant has already been claimed.</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_DONAT_NEXT_DATE" desc="Description of the date in the donation box">Next monthly tip date</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_COMPLIMENT_TWEET" desc="">
I just tipped <ph name="NAME">$1<ex>user</ex></ph> using the Brave Browser. Check it out at https://brave.com/tips.
I just tipped <ph name="NAME">$1<ex>user</ex></ph> on <ph name="PROVIDER">$2<ex>site</ex></ph> using the Brave Browser. Check it out at https://brave.com/tips.
</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_COMPLIMENT_TWEET_HASHTAG" desc="">TipWithBrave</message>

Expand Down

0 comments on commit a07fe59

Please sign in to comment.