import { html, Component } from "../lib/index.js"; import { strip as stripANSI } from "../lib/ansi.js"; import Membership from "./membership.js"; import * as irc from "../lib/irc.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 || this.props.user !== nextProps.user; } handleClick(event) { event.preventDefault(); this.props.onClick(); } render() { let title; let user = this.props.user; let classes = ["nick"]; if (user) { let mask = ""; if (user.username && user.hostname) { mask = `${user.username}@${user.hostname}`; } if (irc.isMeaningfulRealname(user.realname, this.props.nick)) { title = stripANSI(user.realname); if (mask) { title = `${title} (${mask})`; } } else { title = mask; } if (user.account) { title += `\nAuthenticated as ${user.account}`; } if (user.away) { classes.push("away"); title += "\nAway"; } } return html`