[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:
parent
7b694fd860
commit
611ff0c7e4
4 changed files with 162 additions and 51 deletions
|
@ -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})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue