diff --git a/src/css/support.css b/src/css/support.css index d2777dcecb32e..0afd7407a803e 100644 --- a/src/css/support.css +++ b/src/css/support.css @@ -54,12 +54,12 @@ body.filterIssue #moreButton { display: none; } -body.shouldUpdate:not(.updated) .e .createEntry { +body[data-should-update-lists]:not(.updated) .e .createEntry { opacity: 0.25; pointer-events: none; } -body:not(.shouldUpdate) .shouldUpdate { +body:not([data-should-update-lists]) .shouldUpdate { display: none; } body.updating { diff --git a/src/js/messaging.js b/src/js/messaging.js index 443b4bdfaee59..e5d911d393b97 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -602,11 +602,10 @@ const launchReporter = async function(request) { const entries = await io.getUpdateAges({ filters: µb.selectedFilterLists.slice() }); - let shouldUpdateLists = false; + const shouldUpdateLists = []; for ( const entry of entries ) { if ( entry.age < (2 * 60 * 60 * 1000) ) { continue; } - io.purge(entry.assetKey); - shouldUpdateLists = true; + shouldUpdateLists.push(entry.assetKey); } // https://github.com/gorhill/uBlock/commit/6efd8eb#commitcomment-107523558 @@ -634,8 +633,8 @@ const launchReporter = async function(request) { const supportURL = new URL(vAPI.getURL('support.html')); supportURL.searchParams.set('pageURL', request.pageURL); supportURL.searchParams.set('popupPanel', JSON.stringify(request.popupPanel)); - if ( shouldUpdateLists ) { - supportURL.searchParams.set('shouldUpdate', 1); + if ( shouldUpdateLists.length ) { + supportURL.searchParams.set('shouldUpdateLists', JSON.stringify(shouldUpdateLists)); } return supportURL.href; }; diff --git a/src/js/support.js b/src/js/support.js index 80d45cad3c532..891842efc6872 100644 --- a/src/js/support.js +++ b/src/js/support.js @@ -210,8 +210,9 @@ const reportedPage = (( ) => { dom.text(option, parsedURL.href); select.append(option); } - if ( url.searchParams.get('shouldUpdate') !== null ) { - dom.cl.add(dom.body, 'shouldUpdate'); + const shouldUpdateLists = url.searchParams.get('shouldUpdateLists'); + if ( shouldUpdateLists !== null ) { + dom.body.dataset.shouldUpdateLists = shouldUpdateLists; } dom.cl.add(dom.body, 'filterIssue'); return { @@ -250,8 +251,12 @@ function reportSpecificFilterIssue() { } async function updateFilterLists() { + if ( dom.body.dataset.shouldUpdateLists === undefined ) { return false; } dom.cl.add(dom.body, 'updating'); + const assetKeys = JSON.parse(dom.body.dataset.shouldUpdateLists); + vAPI.messaging.send('dashboard', { what: 'purgeCaches', assetKeys }); vAPI.messaging.send('dashboard', { what: 'forceUpdateAssets' }); + return true; } /******************************************************************************/ @@ -281,9 +286,9 @@ uBlockDashboard.patchCodeMirrorEditor(cmEditor); }); if ( reportedPage !== null ) { - if ( dom.cl.has(dom.body, 'shouldUpdate') ) { + if ( dom.body.dataset.shouldUpdateLists ) { dom.on('.supportEntry.shouldUpdate button', 'click', ev => { - updateFilterLists(); + if ( updateFilterLists() === false ) { return; } ev.preventDefault(); }); }