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;
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue