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

Commit

Permalink
Add the option "Hide sites with less than 1% usage"
Browse files Browse the repository at this point in the history
Auditor: @bsclifton
Fixes #4681
  • Loading branch information
mrose17 committed Dec 14, 2016
1 parent 2b315d0 commit 8ae8eb4
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 17 deletions.
3 changes: 2 additions & 1 deletion app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ done=Done
off=off
on=on
ok=Ok
notifications=Show payment notifications
minimumPercentage=Hide sites with less than 1% usage
notifications=Show notifications
moneyAdd=Use your debit/credit card
moneyAddSubTitle=No Bitcoin needed!
outsideUSAPayment=Buy Bitcoin at our recommended source
Expand Down
13 changes: 8 additions & 5 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ const doAction = (action) => {
updatePublisherInfo()
break

case settings.MINIMUM_PERCENTAGE:
updatePublisherInfo()
break

default:
break
}
Expand Down Expand Up @@ -731,7 +735,7 @@ var updatePublisherInfo = () => {
}

var synopsisNormalizer = () => {
var i, duration, n, pct, publisher, results, total
var i, duration, minP, n, pct, publisher, results, total
var data = []
var scorekeeper = synopsis.options.scorekeeper

Expand Down Expand Up @@ -798,16 +802,15 @@ var synopsisNormalizer = () => {
.value()
}

minP = getSetting(settings.MINIMUM_PERCENTAGE)
pct = foo(pct, 100)
total = 0
for (i = 0; i < n; i++) {
/*
if (pct[i] <= 0) {
if (pct[i] < 0) pct[i] = 0
if ((minP) && (pct[i] < 1)) {
data = data.slice(0, i)
break
}
*/
if (pct[i] < 0) pct[i] = 0

data[i].percentage = pct[i]
total += pct[i]
Expand Down
17 changes: 12 additions & 5 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -1048,11 +1048,18 @@ class PaymentsTab extends ImmutableComponent {
</div>
<div className='settingsPanelDivider'>
{this.enabled
? <SettingCheckbox
dataL10nId='notifications'
prefKey={settings.PAYMENTS_NOTIFICATIONS}
settings={this.props.settings}
onChangeSetting={this.props.onChangeSetting} />
? <SettingsList>
<SettingCheckbox
dataL10nId='minimumPercentage'
prefKey={settings.MINIMUM_PERCENTAGE}
settings={this.props.settings}
onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox
dataL10nId='notifications'
prefKey={settings.PAYMENTS_NOTIFICATIONS}
settings={this.props.settings}
onChangeSetting={this.props.onChangeSetting} />
</SettingsList>
: null}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ module.exports = {
'advanced.send-usage-statistics': false,
'advanced.minimum-visit-time': 8,
'advanced.minimum-visits': 5,
'advanced.minimum-percentage': false,
'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 @@ -61,6 +61,7 @@ const settings = {
ADBLOCK_CUSTOM_RULES: 'adblock.customRules',
MINIMUM_VISIT_TIME: 'advanced.minimum-visit-time',
MINIMUM_VISITS: 'advanced.minimum-visits',
MINIMUM_PERCENTAGE: 'advanced.minimum-percentage',

// DEPRECATED settings
// ########################
Expand Down
48 changes: 45 additions & 3 deletions less/about/preferences.less
Original file line number Diff line number Diff line change
Expand Up @@ -895,12 +895,54 @@ div.nextPaymentSubmission {
padding: 25px 20px;

&.advancedSettings {
padding-left: 50px;
padding-right: 50px;
display: flex;
flex-wrap: nowrap;

select {
.settingsPanelDivider {
width: 100%;
}

.settingsPanelDivider:nth-child(1) {
.settingsListContainer:last-child {
margin-bottom: 0;
}
}

.settingsPanelDivider:nth-child(2) {
display: flex;
align-items: center;
width: auto;
margin-left: 1em;

.settingsListContainer:last-child {
margin-bottom: 0;

.settingsList {
display: flex;
flex-flow: column nowrap;
justify-content: space-between;

.settingItem {
display: flex;
margin-bottom: 1em;

&:last-child {
margin-bottom: 0;
}

label {
margin-bottom: 0;
}

.switchControl {
margin-top: 2px;
padding-top: 0;
padding-bottom: 0;
}
}
}
}
}
}

.settingsPanelDivider {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@
"immutablepatch": "brave/immutable-js-patch",
"keytar": "^3.0.0",
"l20n": "^3.5.1",
"ledger-balance": "^0.8.62",
"ledger-client": "^0.8.94",
"ledger-balance": "^0.8.63",
"ledger-client": "^0.8.96",
"ledger-geoip": "^0.8.73",
"ledger-publisher": "^0.8.91",
"ledger-publisher": "^0.8.96",
"lru_cache": "^1.0.0",
"moment": "^2.15.1",
"normalize-url": "^1.7.0",
Expand Down

0 comments on commit 8ae8eb4

Please sign in to comment.