Skip to content

Commit

Permalink
Fixes changing pinned values
Browse files Browse the repository at this point in the history
Resolves brave#12450

Auditors:

Test Plan:
  • Loading branch information
NejcZdovc committed Dec 31, 2017
1 parent f7d8df6 commit 71f8950
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ const synopsisNormalizer = (state, changedPublisher, returnState = true, prune =
// round if over 100% of pinned publishers
if (pinnedTotal > 100) {
if (changedPublisher) {
let changedObject = dataPinned.filter(publisher => publisher.site === changedPublisher)[0] // TOOD optimize to find from filter
let changedObject = dataPinned.filter(publisher => publisher.publisherKey === changedPublisher)[0] // TOOD optimize to find from filter
const setOne = changedObject.pinPercentage > (100 - dataPinned.length - 1)

if (setOne) {
Expand All @@ -436,7 +436,7 @@ const synopsisNormalizer = (state, changedPublisher, returnState = true, prune =
}

const pinnedRestTotal = pinnedTotal - changedObject.pinPercentage
dataPinned = dataPinned.filter(publisher => publisher.site !== changedPublisher)
dataPinned = dataPinned.filter(publisher => publisher.publisherKey !== changedPublisher)
dataPinned = normalizePinned(dataPinned, pinnedRestTotal, (100 - changedObject.pinPercentage), setOne)
dataPinned = roundToTarget(dataPinned, (100 - changedObject.pinPercentage), 'pinPercentage')

Expand Down Expand Up @@ -480,7 +480,7 @@ const synopsisNormalizer = (state, changedPublisher, returnState = true, prune =

// sync synopsis
newData.forEach((item) => {
const publisherKey = item.site
const publisherKey = item.publisherKey
const weight = item.weight
const pinPercentage = item.pinPercentage
savePublisherData(publisherKey, 'weight', weight)
Expand Down

0 comments on commit 71f8950

Please sign in to comment.