2021-03-02 16:46:48 -05:00
|
|
|
import { html, Component } from "../lib/index.js";
|
|
|
|
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>
|
2021-05-27 09:17:18 -04:00
|
|
|
${Array.from(this.props.members).sort().map(([nick, membership]) => html`
|
2020-07-13 05:09:16 -04:00
|
|
|
<${MemberItem} key=${nick} nick=${nick} membership=${membership} onClick=${() => this.props.onNickClick(nick)}/>
|
|
|
|
`)}
|
|
|
|
</ul>
|
|
|
|
`;
|
|
|
|
}
|
2020-06-26 08:32:56 -04:00
|
|
|
}
|