diff --git a/src/client/components/App.js b/src/client/components/App.js index adc122f..e742d41 100644 --- a/src/client/components/App.js +++ b/src/client/components/App.js @@ -3,7 +3,6 @@ import * as constants from '../constants.js' import Toolbar from './Toolbar.js' import Notifications, { NotificationPropTypes } from './Notifications.js' import Chat, { MessagePropTypes } from './Chat.js' -import Input from './Input.js' import PropTypes from 'prop-types' import React from 'react' import Video, { StreamPropType } from './Video.js' @@ -59,12 +58,13 @@ export default class App extends React.PureComponent { /> -
{ this.chatRef = node }}> - - { this.chatRef = node }}> +
diff --git a/src/client/components/Chat.js b/src/client/components/Chat.js index 71ce23f..a6e14ed 100644 --- a/src/client/components/Chat.js +++ b/src/client/components/Chat.js @@ -1,5 +1,7 @@ import PropTypes from 'prop-types' import React from 'react' +import socket from '../socket.js' +import Input from './Input.js' export const MessagePropTypes = PropTypes.shape({ userId: PropTypes.string.isRequired, @@ -10,8 +12,11 @@ export const MessagePropTypes = PropTypes.shape({ export default class Chat extends React.PureComponent { static propTypes = { - toolbarRef: PropTypes.object.isRequired, - messages: PropTypes.arrayOf(MessagePropTypes).isRequired + messages: PropTypes.arrayOf(MessagePropTypes).isRequired, + videos: PropTypes.object.isRequired, + notify: PropTypes.func.isRequired, + sendMessage: PropTypes.func.isRequired, + toolbarRef: PropTypes.object.isRequired } handleCloseChat = e => { const { toolbarRef } = this.props @@ -27,7 +32,7 @@ export default class Chat extends React.PureComponent { this.scrollToBottom() } render () { - const { messages } = this.props + const { messages, videos, notify, sendMessage } = this.props return (
@@ -38,29 +43,36 @@ export default class Chat extends React.PureComponent {
Chat
-
{ this.chatScroll = div }}> +
{ this.chatScroll = div }}> {messages.length ? ( messages.map((message, i) => ( -
-
-
-
- {message.image ? ( -
- -
- ) : ( -
- {message.userId.substr(0, 2).toUpperCase()} -
- )} +
+ {message.userId === socket.id ? ( +
+
+ + {message.userId} + + + +

{message.message}

+
+
-
-
- {message.message} -
+ ) : ( +
+ +
+ + {message.userId} + + + +

{message.message}

+
+
+ )}
)) ) : ( @@ -71,6 +83,12 @@ export default class Chat extends React.PureComponent { )}
+ +
) } diff --git a/src/client/components/Input.js b/src/client/components/Input.js index 011c8e9..12506b0 100644 --- a/src/client/components/Input.js +++ b/src/client/components/Input.js @@ -37,7 +37,11 @@ export default class Input extends React.PureComponent { sendMessage(message) const userId = socket.id - const timestamp = new Date() + const timestamp = new Date().toLocaleString('en-US', { + hour: 'numeric', + minute: 'numeric', + hour12: false + }) let image = null // take snapshoot @@ -61,18 +65,19 @@ export default class Input extends React.PureComponent { render () { const { message } = this.state return ( -
+