Add time since version update in troubleshooting info

This commit is contained in:
Raymond Hill 2023-04-25 14:01:47 -04:00
parent 5e174c6cb5
commit 7e894f5e0e
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 31 additions and 26 deletions

View File

@ -1418,6 +1418,22 @@ const getSupportData = async function() {
filterset.push(line); filterset.push(line);
} }
const now = Date.now();
const formatDelayFromNow = time => {
if ( (time || 0) === 0 ) { return '?'; }
const delayInSec = (now - time) / 1000;
const days = (delayInSec / 86400) | 0;
const hours = (delayInSec % 86400) / 3600 | 0;
const minutes = (delayInSec % 3600) / 60 | 0;
const parts = [];
if ( days > 0 ) { parts.push(`${days}d`); }
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 lists = µb.availableFilterLists; const lists = µb.availableFilterLists;
let defaultListset = {}; let defaultListset = {};
let addedListset = {}; let addedListset = {};
@ -1435,16 +1451,7 @@ const getSupportData = async function() {
if ( typeof list.writeTime !== 'number' || list.writeTime === 0 ) { if ( typeof list.writeTime !== 'number' || list.writeTime === 0 ) {
listDetails.push('never'); listDetails.push('never');
} else { } else {
const delta = (Date.now() - list.writeTime) / 1000 | 0; listDetails.push(formatDelayFromNow(list.writeTime));
const days = (delta / 86400) | 0;
const hours = (delta % 86400) / 3600 | 0;
const minutes = (delta % 3600) / 60 | 0;
const parts = [];
if ( days > 0 ) { parts.push(`${days}d`); }
if ( hours > 0 ) { parts.push(`${hours}h`); }
if ( minutes > 0 ) { parts.push(`${minutes}m`); }
if ( parts.length === 0 ) { parts.push('now'); }
listDetails.push(parts.join('.'));
} }
} }
if ( list.isDefault || listKey === µb.userFiltersPath ) { if ( list.isDefault || listKey === µb.userFiltersPath ) {
@ -1462,18 +1469,22 @@ const getSupportData = async function() {
} }
if ( Object.keys(addedListset).length === 0 ) { if ( Object.keys(addedListset).length === 0 ) {
addedListset = undefined; addedListset = undefined;
} else if ( Object.keys(addedListset).length > 15 ) { } else {
const added = Object.keys(addedListset); const added = Object.keys(addedListset);
const truncated = added.slice(15); const truncated = added.slice(12);
for ( const key of truncated ) { for ( const key of truncated ) {
delete addedListset[key]; delete addedListset[key];
} }
addedListset[`[${truncated.length} lists not shown]`] = '[too many]'; if ( truncated.length !== 0 ) {
addedListset[`[${truncated.length} lists not shown]`] = '[too many]';
}
} }
if ( Object.keys(removedListset).length === 0 ) { if ( Object.keys(removedListset).length === 0 ) {
removedListset = undefined; removedListset = undefined;
} }
const { versionUpdateTime = 0 } = await vAPI.storage.get('versionUpdateTime');
let browserFamily = (( ) => { let browserFamily = (( ) => {
if ( vAPI.webextFlavor.soup.has('firefox') ) { return 'Firefox'; } if ( vAPI.webextFlavor.soup.has('firefox') ) { return 'Firefox'; }
if ( vAPI.webextFlavor.soup.has('chromium') ) { return 'Chromium'; } if ( vAPI.webextFlavor.soup.has('chromium') ) { return 'Chromium'; }
@ -1484,7 +1495,9 @@ const getSupportData = async function() {
} }
return { return {
[`${vAPI.app.name}`]: `${vAPI.app.version}`, [`${vAPI.app.name} ${vAPI.app.version}`]: {
since: formatDelayFromNow(versionUpdateTime),
},
[`${browserFamily}`]: `${vAPI.webextFlavor.major}`, [`${browserFamily}`]: `${vAPI.webextFlavor.major}`,
'filterset (summary)': { 'filterset (summary)': {
network: staticNetFilteringEngine.getFilterCount(), network: staticNetFilteringEngine.getFilterCount(),

View File

@ -148,7 +148,10 @@ const initializeTabs = async ( ) => {
const onVersionReady = lastVersion => { const onVersionReady = lastVersion => {
if ( lastVersion === vAPI.app.version ) { return; } if ( lastVersion === vAPI.app.version ) { return; }
vAPI.storage.set({ version: vAPI.app.version }); vAPI.storage.set({
version: vAPI.app.version,
versionUpdateTime: Date.now(),
});
const lastVersionInt = vAPI.app.intFromVersion(lastVersion); const lastVersionInt = vAPI.app.intFromVersion(lastVersion);
@ -161,17 +164,6 @@ const onVersionReady = lastVersion => {
// Since built-in resources may have changed since last version, we // Since built-in resources may have changed since last version, we
// force a reload of all resources. // force a reload of all resources.
redirectEngine.invalidateResourcesSelfie(io); redirectEngine.invalidateResourcesSelfie(io);
// https://github.com/LiCybora/NanoDefenderFirefox/issues/196
// Toggle on the blocking of CSP reports by default for Firefox.
if (
lastVersionInt <= 1031003011 &&
vAPI.webextFlavor.soup.has('firefox')
) {
sessionSwitches.toggle('no-csp-reports', '*', 1);
permanentSwitches.toggle('no-csp-reports', '*', 1);
µb.saveHostnameSwitches();
}
}; };
/******************************************************************************/ /******************************************************************************/