Skip to content

Commit

Permalink
Auto-include propagates correctly
Browse files Browse the repository at this point in the history
Resolves brave#7451

Auditors: @mrose17

Test Plan:
- Enable payments in settings
- Disable auto-include switch
- Visit brianbondy.com in a new tab, site is added in the list and is not included
  • Loading branch information
NejcZdovc committed Mar 14, 2017
1 parent 5a889cc commit c4094cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,14 @@ eventStore.addChangeListener(() => {
pattern = `https?://${publisher}`
initP = !synopsis.publishers[publisher]
synopsis.initPublisher(publisher)
if ((initP) && (getSetting(settings.AUTO_SUGGEST_SITES))) {
if (initP) {
excludeP(publisher, (unused, exclude) => {
appActions.changeSiteSetting(pattern, 'ledgerPayments', !exclude)
if (!getSetting(settings.AUTO_SUGGEST_SITES)) {
exclude = false
} else {
exclude = !exclude
}
appActions.changeSiteSetting(pattern, 'ledgerPayments', exclude)
updatePublisherInfo()
})
}
Expand Down Expand Up @@ -981,8 +986,12 @@ var stickyP = (publisher) => {
var result = (siteSetting) && (siteSetting.get('ledgerPayments'))

// NB: legacy clean-up
if ((typeof result === 'undefined') && (typeof synopsis.publishers[publisher].options.stickyP !== 'undefined')) {
result = synopsis.publishers[publisher].options.stickyP
if (typeof result === 'undefined') {
if (typeof synopsis.publishers[publisher].options.stickyP !== 'undefined') {
result = synopsis.publishers[publisher].options.stickyP
} else {
result = true
}
appActions.changeSiteSetting(pattern, 'ledgerPayments', result)
}
delete synopsis.publishers[publisher].options.stickyP
Expand Down
6 changes: 3 additions & 3 deletions app/renderer/components/preferences/payment/ledgerTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class LedgerTable extends ImmutableComponent {
return result
}
}
return true
return getSetting(settings.AUTO_SUGGEST_SITES, this.props.settings)
}

shouldShow (synopsis) {
Expand Down Expand Up @@ -101,7 +101,7 @@ class LedgerTable extends ImmutableComponent {
const publisherURL = synopsis.get('publisherURL')
const percentage = synopsis.get('percentage')
const site = synopsis.get('site')
const defaultSiteSetting = true
const defaultAutoInclude = this.enabledForSite(synopsis)

return [
{
Expand Down Expand Up @@ -131,7 +131,7 @@ class LedgerTable extends ImmutableComponent {
{
html: <SiteSettingCheckbox small
hostPattern={this.getHostPattern(synopsis)}
defaultValue={defaultSiteSetting}
defaultValue={defaultAutoInclude}
prefKey='ledgerPayments'
siteSettings={this.props.siteSettings}
checked={this.enabledForSite(synopsis)} />,
Expand Down

0 comments on commit c4094cd

Please sign in to comment.