diff --git a/platform/mv3/extension/js/dashboard.js b/platform/mv3/extension/js/dashboard.js index b8c240d5c..d43f45c5b 100644 --- a/platform/mv3/extension/js/dashboard.js +++ b/platform/mv3/extension/js/dashboard.js @@ -36,3 +36,9 @@ dom.on('#dashboard-nav', 'click', '.tabButton', ev => { }); /******************************************************************************/ + +export function hashFromIterable(iter) { + return Array.from(iter).sort().join('\n'); +} + +/******************************************************************************/ diff --git a/platform/mv3/extension/js/filter-lists.js b/platform/mv3/extension/js/filter-lists.js index ce62dc310..a609a7d53 100644 --- a/platform/mv3/extension/js/filter-lists.js +++ b/platform/mv3/extension/js/filter-lists.js @@ -22,6 +22,7 @@ import { dom, qs$, qsa$ } from './dom.js'; import { i18n, i18n$ } from './i18n.js'; import { localRead, localWrite, sendMessage } from './ext.js'; +import { hashFromIterable } from './dashboard.js'; /******************************************************************************/ @@ -403,6 +404,10 @@ const applyEnabledRulesets = (( ) => { dom.cl.remove('#lists .listEntry.toggled', 'toggled'); + const unmodified = hashFromIterable(enabledRulesets) === + hashFromIterable(cachedRulesetData.enabledRulesets); + if ( unmodified ) { return; } + await sendMessage({ what: 'applyRulesets', enabledRulesets, diff --git a/platform/mv3/extension/js/settings.js b/platform/mv3/extension/js/settings.js index 4c9352f6e..1a7812cbc 100644 --- a/platform/mv3/extension/js/settings.js +++ b/platform/mv3/extension/js/settings.js @@ -21,6 +21,7 @@ import { browser, sendMessage } from './ext.js'; import { dom, qs$ } from './dom.js'; +import { hashFromIterable } from './dashboard.js'; import punycode from './punycode.js'; import { renderFilterLists } from './filter-lists.js'; @@ -30,12 +31,6 @@ let cachedRulesetData = {}; /******************************************************************************/ -function hashFromIterable(iter) { - return Array.from(iter).sort().join('\n'); -} - -/******************************************************************************/ - function renderAdminRules() { const { disabledFeatures: forbid = [] } = cachedRulesetData; if ( forbid.length === 0 ) { return; }