diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/src/components/Transfers/TransferList.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/web/src/components/Transfers/TransferList.js b/src/web/src/components/Transfers/TransferList.js index 78e2e031..94b4b050 100644 --- a/src/web/src/components/Transfers/TransferList.js +++ b/src/web/src/components/Transfers/TransferList.js @@ -40,9 +40,20 @@ const formatBytesTransferred = ({ transferred, size }) => { const [t, tExt] = formatBytes(transferred).split(' ') const [s, sExt] = formatBytes(size).split(' ') - // include the size label for transferred if it differs from size - // e.g. 12 KB/3 MB => 2.9/3 MB - return `${t}${tExt === sExt ? '' : ' ' + tExt}/${s} ${sExt}` + const fmt = (n) => parseFloat(n).toFixed(2); + + // if less than 1 MB has been transferred, don't include decimals + if (tExt === 'KB') { + return `${t} KB/${fmt(s)} ${sExt}` + } + + // if the suffix for size and transferred doesn't match, include + // the suffix for each + if (tExt !== sExt) { + return `${fmt(t)} ${tExt}/${fmt(s)} ${sExt}` + } + + return `${fmt(t)}/${fmt(s)} ${sExt}` } class TransferList extends Component { |
