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

Based on
https://github.com/luixxiul/browser-laptop/commit/86c875616085f755e5ced0
421e7bdc9b2b9e601b and
#6174, but ported to the
0.12-branch
  • Loading branch information
mrose17 committed Dec 14, 2016
1 parent 4a86554 commit 9bfaff5
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 16 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 @@ -65,7 +65,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 @@ -153,6 +153,10 @@ const doAction = (action) => {
updatePublisherInfo()
break

case settings.MINIMUM_PERCENTAGE:
updatePublisherInfo()
break

default:
break
}
Expand Down Expand Up @@ -700,7 +704,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 @@ -767,16 +771,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 @@ -1017,11 +1017,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 @@ -144,6 +144,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 @@ -60,6 +60,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
49 changes: 45 additions & 4 deletions less/about/preferences.less
Original file line number Diff line number Diff line change
Expand Up @@ -828,12 +828,53 @@ div.nextPaymentSubmission {
padding: 20px;

&.advancedSettings {
padding-left: 50px;
padding-right: 50px;

select {
display: flex;
flex-wrap: nowrap;
.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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"immutablepatch": "brave/immutable-js-patch",
"keytar": "^3.0.0",
"l20n": "^3.5.1",
"ledger-balance": "^0.8.62",
"ledger-balance": "^0.8.63",
"ledger-client": "^0.8.94",
"ledger-geoip": "^0.8.73",
"ledger-publisher": "^0.8.91",
Expand Down

1 comment on commit 9bfaff5

@bsclifton
Copy link
Member

Choose a reason for hiding this comment

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

++

Please sign in to comment.