dispatch/client/src/js/components/UserList.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-12-28 23:34:32 +00:00
import React, { Component } from 'react';
import Infinite from 'react-infinite';
import pure from 'pure-render-decorator';
import UserListItem from './UserListItem';
@pure
export default class UserList extends Component {
state = {
height: window.innerHeight - 100
}
componentDidMount() {
window.addEventListener('resize', this.handleResize);
}
componentWillUnmount() {
window.removeEventListener('resize', this.handleResize);
}
handleResize = () => {
this.setState({ height: window.innerHeight - 100 });
}
render() {
const { tab, openPrivateChat, select } = this.props;
const users = [];
const style = {};
if (!tab.channel) {
style.display = 'none';
} else {
2016-01-05 18:29:22 +00:00
this.props.users.forEach(user => users.push(
<UserListItem
key={user.nick}
user={user}
tab={tab}
openPrivateChat={openPrivateChat}
select={select}
/>
));
2015-12-28 23:34:32 +00:00
}
return (
<div className="userlist" style={style}>
<Infinite containerHeight={this.state.height} elementHeight={24}>
{users}
</Infinite>
</div>
);
}
}