2020-06-26 08:32:56 -04:00
|
|
|
import { html, Component } from "/lib/index.js";
|
2020-07-15 12:47:33 -04:00
|
|
|
import { getNickURL } from "/state.js";
|
2020-06-26 08:32:56 -04:00
|
|
|
|
2020-07-13 05:09:16 -04:00
|
|
|
class MemberItem extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.handleClick = this.handleClick.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
shouldComponentUpdate(nextProps) {
|
|
|
|
return this.props.nick !== nextProps.nick;
|
|
|
|
}
|
|
|
|
|
|
|
|
handleClick(event) {
|
2020-06-26 08:32:56 -04:00
|
|
|
event.preventDefault();
|
2020-07-13 05:09:16 -04:00
|
|
|
this.props.onClick();
|
2020-06-26 08:32:56 -04:00
|
|
|
}
|
|
|
|
|
2020-07-13 05:09:16 -04:00
|
|
|
render() {
|
|
|
|
return html`
|
|
|
|
<li>
|
2020-07-15 12:47:33 -04:00
|
|
|
<a href=${getNickURL(this.props.nick)} class="nick" onClick=${this.handleClick}>${this.props.nick}</a>
|
2020-07-13 05:09:16 -04:00
|
|
|
</li>
|
|
|
|
`;
|
|
|
|
}
|
2020-06-26 08:32:56 -04:00
|
|
|
}
|
|
|
|
|
2020-07-13 05:09:16 -04:00
|
|
|
export default class MemberList extends Component {
|
|
|
|
shouldComponentUpdate(nextProps) {
|
|
|
|
return this.props.members !== nextProps.members;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return html`
|
|
|
|
<ul>
|
|
|
|
${Array.from(this.props.members.entries()).sort().map(([nick, membership]) => html`
|
|
|
|
<${MemberItem} key=${nick} nick=${nick} membership=${membership} onClick=${() => this.props.onNickClick(nick)}/>
|
|
|
|
`)}
|
|
|
|
</ul>
|
|
|
|
`;
|
|
|
|
}
|
2020-06-26 08:32:56 -04:00
|
|
|
}
|