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

Inline tipping media data is now generalized #2723

Merged
merged 1 commit into from
Jul 22, 2019
Merged

Conversation

jasonrsadler
Copy link
Contributor

@jasonrsadler jasonrsadler commented Jun 18, 2019

Fixes brave/brave-browser#4907

Submitter Checklist:

Test Plan:

Follow test plan at #2665 and #2195

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@jasonrsadler jasonrsadler changed the title Media inline Inline tipping media data is now generalized Jun 18, 2019
@jasonrsadler jasonrsadler self-assigned this Jun 18, 2019
@jasonrsadler jasonrsadler added this to the 0.68.x - Nightly milestone Jun 18, 2019
@jasonrsadler
Copy link
Contributor Author

Blocked on #2665

@jasonrsadler jasonrsadler changed the base branch from master to reddit-inline June 18, 2019 11:17
@jasonrsadler jasonrsadler force-pushed the media-inline branch 4 times, most recently from cdb70b6 to a700b92 Compare June 18, 2019 12:07
@jasonrsadler jasonrsadler force-pushed the reddit-inline branch 17 times, most recently from eaa3a4f to 93fc6aa Compare June 21, 2019 02:00
"userId": {
"type": "string",
"description": "User ID of tweet author"
},
"name": {
"twitterName": {
"type": "string",
"description": "Name of tweet author"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this description need an update as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. This is still going to a twitter designated function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I misread that diff!

@emerick emerick self-requested a review June 22, 2019 15:52
emerick
emerick previously approved these changes Jun 22, 2019
Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@NejcZdovc
Copy link
Contributor

@jasonrsadler is it possible to merge BraveRewardsTipTwitterUserFunction and BraveRewardsTipRedditUserFunction now that we have the same structure?

@@ -79,7 +79,8 @@ chrome.runtime.onConnect.addListener(function () {
})
})

const tipTwitterUser = (tweetMetaData: RewardsTip.TweetMetaData) => {
const tipTwitterMedia = (mediaMetaData: RewardsTip.MediaMetaData) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we merge tipTwitterMedia and tipTwitterMedia?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment

getTipBanner = (url: string, publisher: RewardsTip.Publisher, tweetMetaData?: RewardsTip.TweetMetaData, redditMetaData?: RewardsTip.RedditMetaData) => {
if (tweetMetaData) {
getTipBanner = (url: string, publisher: RewardsTip.Publisher, mediaMetaData: RewardsTip.MediaMetaData | undefined) => {
if (mediaMetaData && mediaMetaData.mediaType === 'twitter') {
return (
<TipTwitterUser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need separate components for TipTwitterUserand TipRedditUser?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Fixed.

return
}

if (!this.props.mediaMetaData ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check is not needed as you check at the top already

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

if (!this.props.tweetMetaData ||
!this.props.tweetMetaData.tweetText ||
this.props.tweetMetaData.tweetText.length === 0) {
if (!this.props.mediaMetaData || this.props.mediaMetaData.mediaType !== 'twitter') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we save this.props.mediaMetaData into mediaMetaData so that it's cleaner

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (!this.props.redditMetaData ||
!this.props.redditMetaData.postText ||
this.props.redditMetaData.postText.length === 0) {
if (!this.props.mediaMetaData || this.props.mediaMetaData.mediaType !== 'reddit') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments as for twitter text

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -210,9 +216,9 @@ class Banner extends React.Component<Props, State> {
addFundsLink={this.addFundsLink}
>
{
this.props.tweetMetaData
this.props.mediaMetaData && this.props.mediaMetaData.mediaType === 'twitter'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's check first for !this.props.mediaMetaData so that we don't need to check for every platform

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

redditMetaData &&
redditMetaData.postText &&
redditMetaData.postText.length > 0
mediaMetaData &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be on line 40

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file is removed

@jasonrsadler
Copy link
Contributor Author

@jasonrsadler is it possible to merge BraveRewardsTipTwitterUserFunction and BraveRewardsTipRedditUserFunction now that we have the same structure?

I attempted to on the first implementation but in the background.ts portion that gets msg.mediaMetaData, everything builds but at runtime the correct union type can't be inferred and causes missing param errors.


if (mediaMetaData.mediaType === 'twitter') {
const key =
mediaMetaData &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is inside a conditional for mediaMetaData can we remove this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

publisher.title = getLocale(key, { user: mediaMetaData.screenName })
} else if (mediaMetaData.mediaType === 'reddit') {
const key =
mediaMetaData &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jasonrsadler jasonrsadler merged commit e3d935a into master Jul 22, 2019
@jasonrsadler jasonrsadler deleted the media-inline branch July 22, 2019 17:30
@petemill petemill mentioned this pull request Jul 22, 2019
32 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants