1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-04 16:47:15 +02:00

Support pane: mark lists as obsolete only when update button is clicked

Lists older than 2 hours were unconditionally marked as obsolete when
opening the _Support_ pane. Those lists will now be marked as obsolete
only when the _Update now_ button in the _Support_ pane is pressed, i.e.
when launching an update cycle.

Related discussion:
https://github.com/uBlockOrigin/uBlock-discussions/discussions/781#discussioncomment-7287323
This commit is contained in:
Raymond Hill 2023-10-16 07:33:38 -04:00
parent b1530e2659
commit bee64ebd90
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 15 additions and 11 deletions

View File

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

View File

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

View File

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