import { h } from '/js/web_modules/preact.js'; import htm from '/js/web_modules/htm.js'; const html = htm.bind(h); import ChatMessageView from './chat-message-view.js'; import { SOCKET_MESSAGE_TYPES } from '../../utils/websocket.js'; export default function Message(props) { const { message } = props; const { type } = message; if (type === SOCKET_MESSAGE_TYPES.CHAT || type === SOCKET_MESSAGE_TYPES.SYSTEM) { return html`<${ChatMessageView} ...${props} />`; } else if (type === SOCKET_MESSAGE_TYPES.NAME_CHANGE) { const { oldName, newName } = message; return ( html`
${oldName} is now known as ${newName}.
` ); } else { console.log("Unknown message type:", type); } }