diff --git a/webroot/js/chat/chat.js b/webroot/js/chat/chat.js index 280abafef..bc000bade 100644 --- a/webroot/js/chat/chat.js +++ b/webroot/js/chat/chat.js @@ -3,8 +3,8 @@ import htm from 'https://unpkg.com/htm?module'; // Initialize htm with Preact const html = htm.bind(h); -import SOCKET_MESSAGE_TYPES from '../utils/socketMessageTypes.js'; - +import SOCKET_MESSAGE_TYPES from '../utils/socket-message-types.js'; +import Message from './message.js'; export default class Chat extends Component { constructor(props, context) { @@ -47,37 +47,19 @@ export default class Chat extends Component { this.send(nameChange); } - render() { - const { username, userAvatarImage } = this.state; + render(props, state) { + const { username, userAvatarImage } = props; + const { messages } = state; + return ( html`
- messages... - + ${ + messages.map(message => (html`<${Message} message=${message} />`)) + } + messages..
diff --git a/webroot/js/chat/message.js b/webroot/js/chat/message.js index e3f38dda2..90105091a 100644 --- a/webroot/js/chat/message.js +++ b/webroot/js/chat/message.js @@ -6,7 +6,7 @@ const html = htm.bind(h); import { messageBubbleColorForString } from '../utils/user-colors.js'; import { formatMessageText } from '../utils/chat.js'; import { generateAvatar } from '../utils.js'; -import SOCKET_MESSAGE_TYPES from './chat/socket-message-types.js'; +import SOCKET_MESSAGE_TYPES from '../utils/socket-message-types.js'; export default class Message extends Component { render(props) { diff --git a/webroot/js/utils/socketMessageTypes.js b/webroot/js/utils/socket-message-types.js similarity index 100% rename from webroot/js/utils/socketMessageTypes.js rename to webroot/js/utils/socket-message-types.js