feat(taglist): show size with a decimal for images between 1 and 10

fixes #276
This commit is contained in:
Joxit
2022-11-26 22:41:29 +01:00
parent ee93d5bba8
commit 017f6620f0
4 changed files with 10 additions and 4 deletions

View File

@@ -8,7 +8,12 @@ export function bytesToSize(bytes) {
return '0 Byte';
}
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.ceil(bytes / Math.pow(1024, i)) + ' ' + sizes[i];
const number = bytes / Math.pow(1024, i);
if (number < 10) {
const decimal = (bytes - Math.floor(number) * Math.pow(1024, i)) / Math.pow(1024, i);
return `${Math.floor(number)}.${Math.floor(decimal * 10)} ${sizes[i]}`;
}
return Math.ceil(number) + ' ' + sizes[i];
}
export function dateFormat(date) {