Fix number abbreviation when the number is n-thousand (#2261)

This commit fixes the method `abbreviateNumber` so that it behaves as stated in the JSDoc.

Previously, an input of `1234` would have produced `1K`. With this change, the output will be `1.2K`.
This commit is contained in:
Matteo Contrini 2020-08-16 22:35:05 +02:00 committed by GitHub
parent 37ae209ba6
commit e0bc3e9ce4

View File

@ -10,7 +10,7 @@ export default function abbreviateNumber(number: number): string {
if (number >= 1000000) {
return Math.floor(number / 1000000) + app.translator.trans('core.lib.number_suffix.mega_text');
} else if (number >= 1000) {
return Math.floor(number / 1000) + app.translator.trans('core.lib.number_suffix.kilo_text');
return (number / 1000).toFixed(1) + app.translator.trans('core.lib.number_suffix.kilo_text');
} else {
return number.toString();
}