Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Update logic for publishers #7439

Merged
merged 2 commits into from
Mar 2, 2017
Merged

Update logic for publishers #7439

merged 2 commits into from
Mar 2, 2017

Conversation

cezaraugusto
Copy link
Contributor

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Auditors: @mrose17, @bsclifton

Fix #7435
Fix #7089
Fix #7429

Test Plan:

Despite when autoSuggest is OFF, all steps covered by automated test:

npm run test -- --grep="PublisherToggle component"

QA Steps

addFunds toggle is shown by default when

  • Ledger is on
  • Publisher is not permanently removed by user (deleted from publishers list)

addFunds toggle is shown as enabled by default when

  • Auto-suggest is on
  • Not on excluded list (i.e. Google)

addFunds toggle is shown as verified when

  • Site is on verified list (i.e. brianbondy.com)

addFunds toggle is set to ON when

  • Publisher is not enabled for payments

addFunds toggle is set to OFF when

  • Publisher is enabled for payments

Copy link
Member

@mrose17 mrose17 left a comment

Choose a reason for hiding this comment

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

looks great to me!

@bbondy bbondy merged commit 840165e into master Mar 2, 2017
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

Comments left 😄 Nice work!

// If session is clear then siteSettings is undefined and icon
// will never be shown, but synopsis may not be empty.
// In such cases let's check if synopsis matches current publisherId
return !!this.props.synopsis.map(entry => entry.get('site')).includes(this.publisherId)
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this changes from the regular .includes() to a double negate using !!? The double negate is great for making something is truthy (when you don't care about it's value), but in this case includes() should already be returning a bool

const autoSuggestSites = getSetting(settings.AUTO_SUGGEST_SITES)

// hostSettings is undefined until user hit addFunds button.
// For such cases check autoSuggestSites for eligibility.
return this.hostSettings
? this.hostSettings.get('ledgerPayments') !== false
Copy link
Member

Choose a reason for hiding this comment

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

Do all hostSettings entries have a ledgerPayments field? because comparing !== false will be true if that field is undefined. you might want to change this to something like:

return this.hostSettings && typeof this.hostSettings.get('ledgerPayments') === 'boolean'
    ? this.hostSettings.get('ledgerPayments') !== false
    : this.validPublisherSynopsis || (autoSuggestSites && !excluded)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep that's intentional. Ledger only recognizes false values. So if it's not on payment list yet (no user action), field will be undefined. If other conditionals don't apply then we consider it's included for payments.

this.authorizedPublisher && this.verifiedPublisher && styles.fundVerified,
!this.authorizedPublisher && !this.verifiedPublisher && styles.noFundUnverified,
this.authorizedPublisher && !this.verifiedPublisher && styles.fundUnverified
!this.enabledForPaymentsPublisher && this.verifiedPublisher && styles.noFundVerified,
Copy link
Member

Choose a reason for hiding this comment

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

if we wanted to make this cleaner, you could do the && for the two conditions above and store in a const, like

const showNoFundVerified = !this.enabledForPaymentsPublisher && this.verifiedPublisher
// ...
css(
    showNoFundVerified && styles.noFundVerified,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. Will take this for next refactors and just updated Wiki for future reference. Thanks

exclude: boolean, // wheter or not site is in the excluded list
stickyP: boolean, // wheter or not site was added using addFunds urlbar toggle
timestamp: number // timestamp in milliseconds
}
Copy link
Member

Choose a reason for hiding this comment

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

super small nitpick- would be nice to alphabetize these fields. Sublime has this sorting built in; I believe you'd need an add-on for VS Code (cc @NejcZdovc)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we should keep all properties in the state.md sorted alphabetically, so that we can easily read through it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants