blob: ba8dbffcc88a0c9ed708b4c8fc5f3dc79b8a6fb7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import Constants from '../utils/constants.jsx';
import {FormattedRelative, FormattedDate} from 'mm-intl';
var Tooltip = ReactBootstrap.Tooltip;
var OverlayTrigger = ReactBootstrap.OverlayTrigger;
export default class TimeSince extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
this.intervalId = setInterval(() => {
this.forceUpdate();
}, Constants.TIME_SINCE_UPDATE_INTERVAL);
}
componentWillUnmount() {
clearInterval(this.intervalId);
}
render() {
if (this.props.sameUser) {
return (
<time className='post__time'>
<FormattedRelative value={this.props.eventTime} />
</time>
);
}
const tooltip = (
<Tooltip id={'time-since-tooltip-' + this.props.eventTime}>
<FormattedDate
value={this.props.eventTime}
month='long'
day='numeric'
year='numeric'
hour12={true}
hour='numeric'
minute='2-digit'
/>
</Tooltip>
);
return (
<OverlayTrigger
delayShow={Constants.OVERLAY_TIME_DELAY}
placement='top'
overlay={tooltip}
>
<time className='post__time'>
<FormattedRelative value={this.props.eventTime} />
</time>
</OverlayTrigger>
);
}
}
TimeSince.defaultProps = {
eventTime: 0,
sameUser: false
};
TimeSince.propTypes = {
eventTime: React.PropTypes.number.isRequired,
sameUser: React.PropTypes.bool
};
|