From 23633b388d39908f5d4367a2f25a3d8f6580dbc1 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 29 Apr 2020 10:00:58 -0400 Subject: [PATCH] Fix reported "Storage used:" when info is not available --- src/js/settings.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/js/settings.js b/src/js/settings.js index b5a0cc085..a9fa555dd 100644 --- a/src/js/settings.js +++ b/src/js/settings.js @@ -117,10 +117,9 @@ const exportToFile = async function() { /******************************************************************************/ const onLocalDataReceived = function(details) { - let storageUsed; + let v, unit; if ( typeof details.storageUsed === 'number' ) { - let v = details.storageUsed; - let unit; + v = details.storageUsed; if ( v < 1e3 ) { unit = 'genericBytes'; } else if ( v < 1e6 ) { @@ -133,13 +132,14 @@ const onLocalDataReceived = function(details) { v /= 1e9; unit = 'GB'; } - storageUsed = vAPI.i18n('storageUsed') - .replace('{{value}}', v.toLocaleString(undefined, { maximumSignificantDigits: 3 })) - .replace('{{unit}}', vAPI.i18n(unit)); } 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 = { weekday: 'long',