[mv3] Avoid pointless messaging when no changes at beforeunload

This commit is contained in:
Raymond Hill 2025-04-27 09:02:29 -04:00
parent 6c84ae7aba
commit b4aea4ab27
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
3 changed files with 12 additions and 6 deletions

View file

@ -36,3 +36,9 @@ dom.on('#dashboard-nav', 'click', '.tabButton', ev => {
});
/******************************************************************************/
export function hashFromIterable(iter) {
return Array.from(iter).sort().join('\n');
}
/******************************************************************************/

View file

@ -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,

View file

@ -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; }