Skip to content

Commit

Permalink
Add visual hint in support information re. differential update
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gorhill committed Dec 8, 2023
1 parent 310bfec commit 7e44db7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
16 changes: 16 additions & 0 deletions src/js/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -1057,6 +1068,7 @@ async function getRemote(assetKey, options = {}) {
'Diff-Path',
'Diff-Expires',
]);
metadata.diffUpdated = undefined;
assetCacheSetDetails(assetKey, metadata);
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ) {
Expand Down
14 changes: 7 additions & 7 deletions src/js/messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 ) {
Expand Down

0 comments on commit 7e44db7

Please sign in to comment.