Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
at main 23 lines 676 B view raw
1import {useCallback} from 'react' 2import {useLingui} from '@lingui/react' 3 4/** 5 * This matches `formatCount` from `view/com/util/numeric/format.ts`, but has 6 * additional truncation logic for large numbers. `roundingMode` should always 7 * match the original impl, regardless of if we add more formatting here. 8 */ 9export function useFormatPostStatCount() { 10 const {i18n} = useLingui() 11 12 return useCallback( 13 (postStatCount: number) => { 14 const isOver10k = postStatCount >= 10_000 15 return i18n.number(postStatCount, { 16 notation: 'compact', 17 maximumFractionDigits: isOver10k ? 0 : 1, 18 roundingMode: 'trunc', 19 }) 20 }, 21 [i18n], 22 ) 23}