mirror of https://github.com/gorhill/uBlock.git
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:
parent
b1530e2659
commit
bee64ebd90
|
@ -54,12 +54,12 @@ body.filterIssue #moreButton {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.shouldUpdate:not(.updated) .e .createEntry {
|
body[data-should-update-lists]:not(.updated) .e .createEntry {
|
||||||
opacity: 0.25;
|
opacity: 0.25;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
body:not(.shouldUpdate) .shouldUpdate {
|
body:not([data-should-update-lists]) .shouldUpdate {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
body.updating {
|
body.updating {
|
||||||
|
|
|
@ -602,11 +602,10 @@ const launchReporter = async function(request) {
|
||||||
const entries = await io.getUpdateAges({
|
const entries = await io.getUpdateAges({
|
||||||
filters: µb.selectedFilterLists.slice()
|
filters: µb.selectedFilterLists.slice()
|
||||||
});
|
});
|
||||||
let shouldUpdateLists = false;
|
const shouldUpdateLists = [];
|
||||||
for ( const entry of entries ) {
|
for ( const entry of entries ) {
|
||||||
if ( entry.age < (2 * 60 * 60 * 1000) ) { continue; }
|
if ( entry.age < (2 * 60 * 60 * 1000) ) { continue; }
|
||||||
io.purge(entry.assetKey);
|
shouldUpdateLists.push(entry.assetKey);
|
||||||
shouldUpdateLists = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/commit/6efd8eb#commitcomment-107523558
|
// 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'));
|
const supportURL = new URL(vAPI.getURL('support.html'));
|
||||||
supportURL.searchParams.set('pageURL', request.pageURL);
|
supportURL.searchParams.set('pageURL', request.pageURL);
|
||||||
supportURL.searchParams.set('popupPanel', JSON.stringify(request.popupPanel));
|
supportURL.searchParams.set('popupPanel', JSON.stringify(request.popupPanel));
|
||||||
if ( shouldUpdateLists ) {
|
if ( shouldUpdateLists.length ) {
|
||||||
supportURL.searchParams.set('shouldUpdate', 1);
|
supportURL.searchParams.set('shouldUpdateLists', JSON.stringify(shouldUpdateLists));
|
||||||
}
|
}
|
||||||
return supportURL.href;
|
return supportURL.href;
|
||||||
};
|
};
|
||||||
|
|
|
@ -210,8 +210,9 @@ const reportedPage = (( ) => {
|
||||||
dom.text(option, parsedURL.href);
|
dom.text(option, parsedURL.href);
|
||||||
select.append(option);
|
select.append(option);
|
||||||
}
|
}
|
||||||
if ( url.searchParams.get('shouldUpdate') !== null ) {
|
const shouldUpdateLists = url.searchParams.get('shouldUpdateLists');
|
||||||
dom.cl.add(dom.body, 'shouldUpdate');
|
if ( shouldUpdateLists !== null ) {
|
||||||
|
dom.body.dataset.shouldUpdateLists = shouldUpdateLists;
|
||||||
}
|
}
|
||||||
dom.cl.add(dom.body, 'filterIssue');
|
dom.cl.add(dom.body, 'filterIssue');
|
||||||
return {
|
return {
|
||||||
|
@ -250,8 +251,12 @@ function reportSpecificFilterIssue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateFilterLists() {
|
async function updateFilterLists() {
|
||||||
|
if ( dom.body.dataset.shouldUpdateLists === undefined ) { return false; }
|
||||||
dom.cl.add(dom.body, 'updating');
|
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' });
|
vAPI.messaging.send('dashboard', { what: 'forceUpdateAssets' });
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -281,9 +286,9 @@ uBlockDashboard.patchCodeMirrorEditor(cmEditor);
|
||||||
});
|
});
|
||||||
|
|
||||||
if ( reportedPage !== null ) {
|
if ( reportedPage !== null ) {
|
||||||
if ( dom.cl.has(dom.body, 'shouldUpdate') ) {
|
if ( dom.body.dataset.shouldUpdateLists ) {
|
||||||
dom.on('.supportEntry.shouldUpdate button', 'click', ev => {
|
dom.on('.supportEntry.shouldUpdate button', 'click', ev => {
|
||||||
updateFilterLists();
|
if ( updateFilterLists() === false ) { return; }
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue