diff --git a/webroot/index.html b/webroot/index.html index d2a0ff9a5..c3eda8c78 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -36,7 +36,6 @@ - diff --git a/webroot/js/components/chat/message.js b/webroot/js/components/chat/message.js index e208a72dd..c57515088 100644 --- a/webroot/js/components/chat/message.js +++ b/webroot/js/components/chat/message.js @@ -3,7 +3,7 @@ import htm from 'https://unpkg.com/htm?module'; const html = htm.bind(h); import { messageBubbleColorForString } from '../../utils/user-colors.js'; -import { formatMessageText } from '../../utils/chat.js'; +import { formatMessageText, formatTimestamp } from '../../utils/chat.js'; import { generateAvatar } from '../../utils/helpers.js'; import { SOCKET_MESSAGE_TYPES } from '../../utils/websocket.js'; @@ -13,9 +13,10 @@ export default class Message extends Component { const { type } = message; if (type === SOCKET_MESSAGE_TYPES.CHAT) { - const { image, author, body } = message; + const { image, author, body, timestamp } = message; const formattedMessage = formatMessageText(body, username); const avatar = image || generateAvatar(author); + const formattedTimestamp = formatTimestamp(timestamp); const authorColor = messageBubbleColorForString(author); const avatarBgColor = { backgroundColor: authorColor }; @@ -35,6 +36,7 @@ export default class Message extends Component {
= 1) { + return `Sent at ${sentAt.toLocaleDateString('en-US', {dateStyle: 'medium'})} at ` + + sentAt.toLocaleTimeString(); + } + + return `Sent at ${sentAt.toLocaleTimeString()}`; +}