mastodon/app/assets/javascripts/components/components/status_list.jsx

40 lines
1.1 KiB
React
Raw Normal View History

import Status from './status';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PureRenderMixin from 'react-addons-pure-render-mixin';
const StatusList = React.createClass({
propTypes: {
statuses: ImmutablePropTypes.list.isRequired,
onReply: React.PropTypes.func,
onReblog: React.PropTypes.func,
2016-09-22 01:08:35 +02:00
onFavourite: React.PropTypes.func,
onScrollToBottom: React.PropTypes.func
},
mixins: [PureRenderMixin],
2016-09-22 01:08:35 +02:00
handleScroll (e) {
const { scrollTop, scrollHeight, clientHeight } = e.target;
if (scrollTop === scrollHeight - clientHeight) {
this.props.onScrollToBottom();
}
},
render () {
return (
2016-09-22 01:08:35 +02:00
<div style={{ overflowY: 'scroll', flex: '1 1 auto' }} className='scrollable' onScroll={this.handleScroll}>
<div>
{this.props.statuses.map((status) => {
return <Status key={status.get('id')} status={status} onReply={this.props.onReply} onReblog={this.props.onReblog} onFavourite={this.props.onFavourite} />;
})}
</div>
</div>
);
}
});
export default StatusList;