import { html, Component } from "../lib/index.js"; import { getNickURL } from "../state.js"; import { strip as stripANSI } from "../lib/ansi.js"; import Membership from "./membership.js"; class MemberItem extends Component { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); } shouldComponentUpdate(nextProps) { return this.props.nick !== nextProps.nick || this.props.membership !== nextProps.membership; } handleClick(event) { event.preventDefault(); this.props.onClick(); } render() { // XXX: If we were feeling creative we could generate unique colors for // each item in ISUPPORT CHANMODES. But I am not feeling creative. const membmap = { "~": "owner", "&": "admin", "@": "op", "%": "halfop", "+": "voice", }; const membclass = membmap[this.props.membership[0]] || ""; let membership = ""; if (this.props.membership) { membership = html` ${this.props.membership} `; }; let title = null; let user = this.props.user; if (user) { let mask = ""; if (user.username && user.hostname) { mask = `${user.username}@${user.hostname}`; } if (user.realname) { title = stripANSI(user.realname); if (mask) { title = `${title} (${mask})`; } } else { title = mask; } } return html`