Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame
765 Bytes
// @flow
import * as React from 'react';
import { timeDifferenceShort } from 'shared/time-difference';
import { Timestamp } from './style';
import type { HeaderProps } from './index';
class ThreadTimestamp extends React.Component<HeaderProps> {
render() {
const { thread, active } = this.props;
const now = new Date().getTime();
const then = thread.lastActive || thread.createdAt;
let timestamp = timeDifferenceShort(now, new Date(then).getTime());
// show 'just now' instead of '0s' for new threads
if (timestamp.slice(-1) === 's') {
timestamp = 'Just now';
}
return (
<React.Fragment>
<Timestamp active={active}>{timestamp}</Timestamp>
</React.Fragment>
);
}
}
export default ThreadTimestamp;