Fix reported "Storage used:" when info is not available

This commit is contained in:
Raymond Hill 2020-04-29 10:00:58 -04:00
parent 3efee017cf
commit 23633b388d
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -117,10 +117,9 @@ const exportToFile = async function() {
/******************************************************************************/ /******************************************************************************/
const onLocalDataReceived = function(details) { const onLocalDataReceived = function(details) {
let storageUsed; let v, unit;
if ( typeof details.storageUsed === 'number' ) { if ( typeof details.storageUsed === 'number' ) {
let v = details.storageUsed; v = details.storageUsed;
let unit;
if ( v < 1e3 ) { if ( v < 1e3 ) {
unit = 'genericBytes'; unit = 'genericBytes';
} else if ( v < 1e6 ) { } else if ( v < 1e6 ) {
@ -133,13 +132,14 @@ const onLocalDataReceived = function(details) {
v /= 1e9; v /= 1e9;
unit = 'GB'; unit = 'GB';
} }
storageUsed = vAPI.i18n('storageUsed')
.replace('{{value}}', v.toLocaleString(undefined, { maximumSignificantDigits: 3 }))
.replace('{{unit}}', vAPI.i18n(unit));
} else { } else {
storageUsed = '?'; v = '?';
unit = '';
} }
uDom.nodeFromId('storageUsed').textContent = storageUsed; uDom.nodeFromId('storageUsed').textContent =
vAPI.i18n('storageUsed')
.replace('{{value}}', v.toLocaleString(undefined, { maximumSignificantDigits: 3 }))
.replace('{{unit}}', unit && vAPI.i18n(unit) || '');
const timeOptions = { const timeOptions = {
weekday: 'long', weekday: 'long',