From 60ce67309c19196f0781993b94ff3de23225fc28 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Sat, 9 Jan 2021 20:39:59 -0500 Subject: [PATCH] Updated numbers util to truncate MILLIONS (!) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Updated: - numbers util to truncate MILLIONS --- app/javascript/gabsocial/utils/numbers.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/javascript/gabsocial/utils/numbers.js b/app/javascript/gabsocial/utils/numbers.js index 727d5483..63e3bc96 100644 --- a/app/javascript/gabsocial/utils/numbers.js +++ b/app/javascript/gabsocial/utils/numbers.js @@ -14,9 +14,13 @@ export const shortNumberFormat = (number) => { } } + const isMillions = number > 999999 + const isThousands = number > 999 && !isMillions + const divisor = isMillions ? 1000000 : isThousands ? 1000 : 1 + const suffix = isMillions ? 'm' : isThousands ? 'k' : '' return ( - k + {suffix} ) }