From 8b847c8f25e6f08ea690f5334c0a6057622bd399 Mon Sep 17 00:00:00 2001 From: Cezar Augusto Date: Mon, 10 Jul 2017 23:55:35 -0300 Subject: [PATCH] Do not delete exclusion's list website if enabled by publisherToggle Fix #9938 --- app/ledger.js | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/app/ledger.js b/app/ledger.js index 6d0d1802ae9..6ec6d4e9632 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -1070,20 +1070,37 @@ var visibleP = (publisher) => { synopsis.options.showOnlyVerified = getSetting(settings.PAYMENTS_NON_VERIFIED) } + const publisherOptions = synopsis.publishers[publisher].options const onlyVerified = !synopsis.options.showOnlyVerified - return ( - eligibleP(publisher) && - ( - synopsis.publishers[publisher].options.exclude !== true || - stickyP(publisher) - ) && - ( - (onlyVerified && synopsis.publishers[publisher].options && synopsis.publishers[publisher].options.verified) || - !onlyVerified - ) - ) && - !blockedP(publisher) + // Publisher Options + const excludedByUser = blockedP(publisher) + const eligibleByPublisherToggle = stickyP(publisher) != null + const eligibleByNumberOfVisits = eligibleP(publisher) + const isInExclusionList = publisherOptions && publisherOptions.exclude + const verifiedPublisher = publisherOptions && publisherOptions.verified + + // websites not included in exclusion list are eligible by number of visits + // but can be enabled by user action in the publisher toggle + const isEligible = (eligibleByNumberOfVisits && !isInExclusionList) || eligibleByPublisherToggle + + // If user decide to remove the website, don't show it. + if (excludedByUser) { + return false + } + + // Unless user decided to enable publisher with publisherToggle, + // do not show exclusion list. + if (!eligibleByPublisherToggle && isInExclusionList) { + return false + } + + // If verified option is set, only show verified publishers + if (isEligible && onlyVerified) { + return verifiedPublisher + } + + return isEligible } var contributeP = (publisher) => {