[Clipclops] Add clop sent time to clipclop (#3772)

* add message sent time to message

* fix last message in group logic
This commit is contained in:
Samuel Newman 2024-04-30 19:31:30 +01:00 committed by GitHub
parent 7b694fd860
commit 611ff0c7e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 162 additions and 51 deletions

View file

@ -6,17 +6,21 @@ import {ago} from 'lib/strings/time'
export function TimeElapsed({
timestamp,
children,
timeToString = ago,
}: {
timestamp: string
children: ({timeElapsed}: {timeElapsed: string}) => JSX.Element
timeToString?: (timeElapsed: string) => string
}) {
const tick = useTickEveryMinute()
const [timeElapsed, setTimeAgo] = React.useState(() => ago(timestamp))
const [timeElapsed, setTimeAgo] = React.useState(() =>
timeToString(timestamp),
)
const [prevTick, setPrevTick] = React.useState(tick)
if (prevTick !== tick) {
setPrevTick(tick)
setTimeAgo(ago(timestamp))
setTimeAgo(timeToString(timestamp))
}
return children({timeElapsed})