Skip to content

Commit

Permalink
Add "toOverwrite.filters" entry as managed storage property
Browse files Browse the repository at this point in the history
The new entry is an array of strings, each representing a
distinct line, and all entries are used to populate the
"My filters" pane.

This offers an more straightforward way for administrators
to specify a list of custom filters to use for all
installations.
  • Loading branch information
gorhill committed Jan 10, 2021
1 parent 055f37d commit 649b348
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions platform/chromium/managed_storage.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"title": "Settings to overwrite at launch time",
"type": "object",
"properties": {
"filters": {
"title": "A collection of filters",
"description": "The set of user filters to use at launch time -- where each entry is a distinct line.",
"type": "array",
"items": { "type": "string" }
},
"filterLists": {
"title": "A collection of list identifiers and/or list URLs",
"description": "The set of filter lists to use at launch time.",
Expand Down
7 changes: 6 additions & 1 deletion src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,12 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
vAPI.storage.set(bin);
}

if ( typeof data.userFilters === 'string' ) {
if (
Array.isArray(toOverwrite.filters) &&
toOverwrite.filters.length !== 0
) {
this.saveUserFilters(toOverwrite.filters.join('\n'));
} else if ( typeof data.userFilters === 'string' ) {
this.saveUserFilters(data.userFilters);
}
};
Expand Down

0 comments on commit 649b348

Please sign in to comment.