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 5e5a5294c3
commit a9eb14889e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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();
}