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
|
2016-01-06 23:28:11 +00:00
|
|
|
};
|
2015-12-28 23:34:32 +00:00
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
window.addEventListener('resize', this.handleResize);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
window.removeEventListener('resize', this.handleResize);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleResize = () => {
|
|
|
|
this.setState({ height: window.innerHeight - 100 });
|
2016-01-06 23:28:11 +00:00
|
|
|
};
|
2015-12-28 23:34:32 +00:00
|
|
|
|
|
|
|
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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|