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

Commit

Permalink
Merge pull request #12314 from NejcZdovc/hotfix/#12313-disable
Browse files Browse the repository at this point in the history
Adds option to disable promotions
  • Loading branch information
bsclifton authored Dec 22, 2017
2 parents ea04284 + 6582ba8 commit 4028c66
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2418,6 +2418,10 @@ const onMediaPublisher = (state, mediaKey, response, duration, revisited) => {
}

const getPromotion = (state) => {
if (!getSetting(settings.PAYMENTS_ALLOW_PROMOTIONS)) {
return
}

let tempClient = client
let paymentId = null
if (!tempClient) {
Expand Down
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ pageNofMText=Page {{n}} of {{m}}
paintTabs=Show tabs in page theme color
passwordManager=Password Manager
passwordsAndForms=Passwords and Forms
paymentsAllowPromotions=Notify me about token promotions
paymentHistoryDueFooterText=Your next contribution is due.
paymentHistoryFooterText=Your next contribution is {{reconcileDate}}.
paymentHistoryIcon.title=Your Payment History
Expand Down
1 change: 1 addition & 0 deletions app/renderer/components/preferences/advancedTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class AdvancedTab extends ImmutableComponent {
<SettingCheckbox dataL10nId='useSmoothScroll' prefKey={settings.SMOOTH_SCROLL_ENABLED} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='sendCrashReports' prefKey={settings.SEND_CRASH_REPORTS} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='sendUsageStatistics' prefKey={settings.SEND_USAGE_STATISTICS} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='paymentsAllowPromotions' prefKey={settings.PAYMENTS_ALLOW_PROMOTIONS} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
</SettingsList>

<DefaultSectionTitle data-l10n-id='toolbarUserInterfaceScale' />
Expand Down
1 change: 1 addition & 0 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ module.exports = {
'advanced.send-usage-statistics': false,
'advanced.toolbar-ui-scale': 'normal',
'advanced.swipe-nav-distance': 101,
'advanced.payments-allow-promotions': true,
'shutdown.clear-history': false,
'shutdown.clear-downloads': false,
'shutdown.clear-cache': false,
Expand Down
1 change: 1 addition & 0 deletions js/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const settings = {
ADBLOCK_CUSTOM_RULES: 'adblock.customRules',
TOOLBAR_UI_SCALE: 'advanced.toolbar-ui-scale',
SWIPE_NAV_DISTANCE: 'advanced.swipe-nav-distance',
PAYMENTS_ALLOW_PROMOTIONS: 'advanced.payments-allow-promotions',
// Sync settings
SYNC_ENABLED: 'sync.enabled',
SYNC_DEVICE_NAME: 'sync.device-name',
Expand Down
11 changes: 11 additions & 0 deletions test/unit/app/browser/api/ledgerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('ledger api unit tests', function () {
let contributionAmount = 25
let paymentsMinVisitTime = 5000
let paymentsNotifications = true
let paymentsAllowPromotions = true

// spies
let ledgerTransitionSpy
Expand Down Expand Up @@ -77,6 +78,8 @@ describe('ledger api unit tests', function () {
return paymentsMinVisitTime
case settings.PAYMENTS_NOTIFICATIONS:
return paymentsNotifications
case settings.PAYMENTS_ALLOW_PROMOTIONS:
return paymentsAllowPromotions
}
return false
}
Expand Down Expand Up @@ -1376,6 +1379,14 @@ describe('ledger api unit tests', function () {
ledgerClient.reset()
})

it('promotions are disabled', function () {
paymentsAllowPromotions = false
ledgerApi.getPromotion(defaultAppState)
assert(ledgerClient.notCalled)
assert(ledgergetPromotionSpy.notCalled)
paymentsAllowPromotions = true
})

it('empty client', function () {
const oldClient = ledgerApi.getClient()
ledgerApi.setClient(undefined)
Expand Down

0 comments on commit 4028c66

Please sign in to comment.