Add an Intl polyfill
This commit is contained in:
@ -4,21 +4,12 @@ import {
|
||||
FormattedRelative
|
||||
} from 'react-intl';
|
||||
|
||||
const RelativeTimestamp = ({ timestamp, now }) => {
|
||||
const diff = (new Date(now)) - (new Date(timestamp));
|
||||
|
||||
if (diff < 0) {
|
||||
return <FormattedMessage id='relative_time.just_now' defaultMessage='Just now' />
|
||||
} else if (diff > (3600 * 24 * 7 * 1000)) {
|
||||
return <FormattedDate value={timestamp} />
|
||||
} else {
|
||||
return <FormattedRelative value={timestamp} initialNow={now} updateInterval={0} />
|
||||
}
|
||||
const RelativeTimestamp = ({ timestamp }) => {
|
||||
return <FormattedRelative value={new Date(timestamp)} />;
|
||||
};
|
||||
|
||||
RelativeTimestamp.propTypes = {
|
||||
timestamp: React.PropTypes.string.isRequired,
|
||||
now: React.PropTypes.any
|
||||
timestamp: React.PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
export default RelativeTimestamp;
|
||||
|
@ -18,22 +18,8 @@ const StatusList = React.createClass({
|
||||
};
|
||||
},
|
||||
|
||||
getInitialState () {
|
||||
return {
|
||||
now: (new Date()).toString()
|
||||
};
|
||||
},
|
||||
|
||||
mixins: [PureRenderMixin],
|
||||
|
||||
componentDidMount () {
|
||||
this._interval = setInterval(() => this.setState({ now: (new Date()).toString() }), 60000);
|
||||
},
|
||||
|
||||
componentWillUnmount () {
|
||||
clearInterval(this._interval);
|
||||
},
|
||||
|
||||
handleScroll (e) {
|
||||
const { scrollTop, scrollHeight, clientHeight } = e.target;
|
||||
|
||||
@ -61,7 +47,7 @@ const StatusList = React.createClass({
|
||||
<div className='scrollable' onScroll={this.handleScroll}>
|
||||
<div>
|
||||
{statusIds.map((statusId) => {
|
||||
return <StatusContainer key={statusId} id={statusId} now={this.state.now} />;
|
||||
return <StatusContainer key={statusId} id={statusId} />;
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user