mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at localize-dates 36 lines 841 B view raw
1import Graphemer from 'graphemer' 2import {useCallback, useMemo} from 'react' 3 4export const useGrapheme = () => { 5 const splitter = useMemo(() => new Graphemer(), []) 6 7 const getGraphemeString = useCallback( 8 (name: string, length: number) => { 9 let remainingCharacters = 0 10 11 if (name.length > length) { 12 const graphemes = splitter.splitGraphemes(name) 13 14 if (graphemes.length > length) { 15 remainingCharacters = 0 16 name = `${graphemes.slice(0, length).join('')}...` 17 } else { 18 remainingCharacters = length - graphemes.length 19 name = graphemes.join('') 20 } 21 } else { 22 remainingCharacters = length - name.length 23 } 24 25 return { 26 name, 27 remainingCharacters, 28 } 29 }, 30 [splitter], 31 ) 32 33 return { 34 getGraphemeString, 35 } 36}