From 7e44db763e3e4dd1098d4e84716d4cea790f0a2e Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 8 Dec 2023 15:28:20 -0500 Subject: [PATCH] Add visual hint in support information re. differential update In Support pane's troubleshooting information, a delta sign will be added to list update information when the list was last updated through differential update. --- src/js/assets.js | 16 ++++++++++++++++ src/js/messaging.js | 14 +++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/js/assets.js b/src/js/assets.js index 95641d5c40705..a6b9b73367325 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -985,6 +985,17 @@ assets.get = async function(assetKey, options = {}) { silent: options.silent === true, }); registerAssetSource(assetKey, { error: undefined }); + if ( assetDetails.content === 'filters' ) { + const metadata = extractMetadataFromList(details.content, [ + 'Last-Modified', + 'Expires', + 'Diff-Name', + 'Diff-Path', + 'Diff-Expires', + ]); + metadata.diffUpdated = undefined; + assetCacheSetDetails(assetKey, metadata); + } } return reportBack(details.content, contentURL); } @@ -1057,6 +1068,7 @@ async function getRemote(assetKey, options = {}) { 'Diff-Path', 'Diff-Expires', ]); + metadata.diffUpdated = undefined; assetCacheSetDetails(assetKey, metadata); } @@ -1113,6 +1125,9 @@ assets.metadata = async function() { const obsoleteAfter = cacheEntry.writeTime + getUpdateAfterTime(assetKey); assetEntry.obsolete = obsoleteAfter < now; assetEntry.remoteURL = cacheEntry.remoteURL; + if ( cacheEntry.diffUpdated ) { + assetEntry.diffUpdated = cacheEntry.diffUpdated; + } } else if ( assetEntry.contentURL && assetEntry.contentURL.length !== 0 @@ -1273,6 +1288,7 @@ async function diffUpdater() { content: data.text, resourceTime: metadata.lastModified || 0, }); + metadata.diffUpdated = true; assetCacheSetDetails(data.assetKey, metadata); updaterUpdated.push(data.assetKey); } else if ( data.error ) { diff --git a/src/js/messaging.js b/src/js/messaging.js index 3af9be7c940b4..eef19693f5bd7 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -1447,7 +1447,9 @@ const getSupportData = async function() { const now = Date.now(); - const formatDelayFromNow = time => { + const formatDelayFromNow = list => { + const time = list.writeTime; + if ( typeof time !== 'number' || time === 0 ) { return 'never'; } if ( (time || 0) === 0 ) { return '?'; } const delayInSec = (now - time) / 1000; const days = (delayInSec / 86400) | 0; @@ -1458,7 +1460,9 @@ const getSupportData = async function() { if ( hours > 0 ) { parts.push(`${hours}h`); } if ( minutes > 0 ) { parts.push(`${minutes}m`); } if ( parts.length === 0 ) { parts.push('now'); } - return parts.join('.'); + const out = parts.join('.'); + if ( list.diffUpdated ) { return `${out} Δ`; } + return out; }; const lists = µb.availableFilterLists; @@ -1475,11 +1479,7 @@ const getSupportData = async function() { if ( typeof list.entryCount === 'number' ) { listDetails.push(`${list.entryCount}-${list.entryCount-list.entryUsedCount}`); } - if ( typeof list.writeTime !== 'number' || list.writeTime === 0 ) { - listDetails.push('never'); - } else { - listDetails.push(formatDelayFromNow(list.writeTime)); - } + listDetails.push(formatDelayFromNow(list)); } if ( list.isDefault || listKey === µb.userFiltersPath ) { if ( used ) {