import * as irc from "../lib/irc.js"; import { html, Component } from "../lib/index.js"; import { BufferType, Unread, ServerStatus, getBufferURL, getServerName } from "../state.js"; function BufferItem(props) { function handleClick(event) { event.preventDefault(); props.onClick(); } function handleMouseDown(event) { if (event.button === 1) { // middle click event.preventDefault(); props.onClose(); } } let name = props.buffer.name; if (props.buffer.type == BufferType.SERVER) { name = getServerName(props.server, props.bouncerNetwork); } let classes = ["type-" + props.buffer.type]; if (props.active) { classes.push("active"); } if (props.buffer.unread != Unread.NONE) { classes.push("unread-" + props.buffer.unread); } if (props.buffer.type === BufferType.SERVER) { let isError = props.server.status === ServerStatus.DISCONNECTED; if (props.bouncerNetwork && props.bouncerNetwork.error) { isError = true; } if (isError) { classes.push("error"); } } return html`