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

Configure Feed

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

at remove_new_user_progress_guide 29 lines 724 B view raw
1import React from 'react' 2 3import {useGetTimeAgo} from '#/lib/hooks/useTimeAgo' 4import {useTickEveryMinute} from '#/state/shell' 5 6export function TimeElapsed({ 7 timestamp, 8 children, 9 timeToString, 10}: { 11 timestamp: string 12 children: ({timeElapsed}: {timeElapsed: string}) => JSX.Element 13 timeToString?: (timeElapsed: string) => string 14}) { 15 const ago = useGetTimeAgo() 16 const format = timeToString ?? ago 17 const tick = useTickEveryMinute() 18 const [timeElapsed, setTimeAgo] = React.useState(() => 19 format(timestamp, tick), 20 ) 21 22 const [prevTick, setPrevTick] = React.useState(tick) 23 if (prevTick !== tick) { 24 setPrevTick(tick) 25 setTimeAgo(format(timestamp, tick)) 26 } 27 28 return children({timeElapsed}) 29}