From 8ae8eb4aedfdf19936015427a4864315246c56da Mon Sep 17 00:00:00 2001 From: Marshall Rose Date: Tue, 13 Dec 2016 19:52:57 -0800 Subject: [PATCH] Add the option "Hide sites with less than 1% usage" Auditor: @bsclifton Fixes #4681 --- .../locales/en-US/preferences.properties | 3 +- app/ledger.js | 13 +++-- js/about/preferences.js | 17 +++++-- js/constants/appConfig.js | 1 + js/constants/settings.js | 1 + less/about/preferences.less | 48 +++++++++++++++++-- package.json | 6 +-- 7 files changed, 72 insertions(+), 17 deletions(-) diff --git a/app/extensions/brave/locales/en-US/preferences.properties b/app/extensions/brave/locales/en-US/preferences.properties index 37318aed38c..c832cfaf766 100644 --- a/app/extensions/brave/locales/en-US/preferences.properties +++ b/app/extensions/brave/locales/en-US/preferences.properties @@ -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 diff --git a/app/ledger.js b/app/ledger.js index 4f1b77ac28a..a204f85b777 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -159,6 +159,10 @@ const doAction = (action) => { updatePublisherInfo() break + case settings.MINIMUM_PERCENTAGE: + updatePublisherInfo() + break + default: break } @@ -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 @@ -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] diff --git a/js/about/preferences.js b/js/about/preferences.js index ea747725a50..7db8c173044 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -1048,11 +1048,18 @@ class PaymentsTab extends ImmutableComponent {
{this.enabled - ? + ? + + + : null}
diff --git a/js/constants/appConfig.js b/js/constants/appConfig.js index f48d4040703..3952c4e345e 100644 --- a/js/constants/appConfig.js +++ b/js/constants/appConfig.js @@ -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, diff --git a/js/constants/settings.js b/js/constants/settings.js index afec64e98fe..c2ca6980839 100644 --- a/js/constants/settings.js +++ b/js/constants/settings.js @@ -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 // ######################## diff --git a/less/about/preferences.less b/less/about/preferences.less index b95cdbe5c6a..927e1146a74 100644 --- a/less/about/preferences.less +++ b/less/about/preferences.less @@ -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 { diff --git a/package.json b/package.json index 2e8f820400d..22cf0862343 100644 --- a/package.json +++ b/package.json @@ -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",