-
Notifications
You must be signed in to change notification settings - Fork 20
do now allow duplicated items for resources blocked #43
Conversation
- this allows iterating of iterators which is useful for array deduping using Set() for example @see https://www.typescriptlang.org/docs/handbook/iterators-and-generators.html
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
export const unique = (arr: Array<string>) => [...new Set(arr)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice way to deduplicate items :)
const newProps = Object.assign(fakeProps, { | ||
adsBlockedResources: [ | ||
'https://everbodys-got-something-to-hide-except-me-and-my-monkey.cool', | ||
'https://everbodys-got-something-to-hide-except-me-and-my-monkey.cool' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐒
app/state/shieldsPanelState.ts
Outdated
@@ -74,22 +75,22 @@ export const updateResourceBlocked: shieldState.UpdateResourceBlocked = (state, | |||
|
|||
if (blockType === 'ads') { | |||
tabs[tabId].adsBlocked++ | |||
tabs[tabId].adsBlockedResources = [ ...tabs[tabId].adsBlockedResources, subresource ] | |||
tabs[tabId].adsBlockedResources = unique([ ...tabs[tabId].adsBlockedResources, subresource ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our block counts will not match the counts of resources we are showing, I think it might be better to match both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe set adsBlocked
to the length of adsBlockedResources after this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing to request changes for the comment.
- auditors: @yrliou addresses #42 (review)
ok ready w/ updates:
Note: an ad that is also blocked as tracker is kept as-is and not deduped. Visiting https://cezaraugusto.net will show 2 resources blocked with the same analytics url. Workaround for this took a lot of code changes and not worth the effort. Better take would be just making clear for adblock what/what not is an ad/tracker. |
fix brave/brave-browser#420
Test Plan:
covered by automated tests