From 885b3ea6c0600b1e9d50fc1100b5cc6a3724d166 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 27 Mar 2023 15:04:44 -0400 Subject: [PATCH] Fix spurious update cycle attempts Caused by the fact that external filter lists do not have an `off` property even when they are not enabled. Additionally, set the default update cycle check period to 2hr. --- src/js/background.js | 2 +- src/js/storage.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index d3fcae4a1..402500694 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -50,7 +50,7 @@ const hiddenSettingsDefault = { autoCommentFilterTemplate: '{{date}} {{origin}}', autoUpdateAssetFetchPeriod: 60, autoUpdateDelayAfterLaunch: 105, - autoUpdatePeriod: 4, + autoUpdatePeriod: 2, benchmarkDatasetURL: 'unset', blockingProfiles: '11111/#F00 11010/#C0F 11001/#00F 00001', cacheStorageAPI: 'unset', diff --git a/src/js/storage.js b/src/js/storage.js index ba535434a..236be9e4d 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -1481,9 +1481,13 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { const now = Date.now(); let needEmergencyUpdate = false; - for ( const asset of Object.values(assetDict) ) { + for ( const [ assetKey, asset ] of Object.entries(assetDict) ) { if ( asset.hasRemoteURL !== true ) { continue; } - if ( asset.content === 'filters' && asset.off === true ) { continue; } + if ( asset.content === 'filters' ) { + if ( µb.selectedFilterLists.includes(assetKey) === false ) { + continue; + } + } if ( asset.obsolete !== true ) { continue; } const lastUpdateInDays = (now - asset.writeTime) / 86400000; const daysSinceVeryObsolete = lastUpdateInDays - 2 * asset.updateAfter; @@ -1602,7 +1606,9 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { this.loadFilterLists(); } if ( this.userSettings.autoUpdate ) { - this.scheduleAssetUpdater(this.hiddenSettings.autoUpdatePeriod * 3600000 || 25200000); + this.scheduleAssetUpdater( + this.hiddenSettings.autoUpdatePeriod * 3600000 || 25200000 + ); } else { this.scheduleAssetUpdater(0); }