diff --git a/react/features/chat/components/AbstractChatMessage.js b/react/features/chat/components/AbstractChatMessage.js index 4ef592c8e..822896fdb 100644 --- a/react/features/chat/components/AbstractChatMessage.js +++ b/react/features/chat/components/AbstractChatMessage.js @@ -19,12 +19,24 @@ export type Props = { */ message: Object, + /** + * Whether or not the avatar image of the participant which sent the message + * should be displayed. + */ + showAvatar: boolean, + /** * Whether or not the name of the participant which sent the message should * be displayed. */ showDisplayName: boolean, + /** + * Whether or not the time at which the message was sent should be + * displayed. + */ + showTimestamp: boolean, + /** * Invoked to receive translated strings. */ @@ -36,7 +48,9 @@ export type Props = { */ export default class AbstractChatMessage extends PureComponent

{ static defaultProps = { - showDisplayName: true + showAvatar: false, + showDisplayName: false, + showTimestamp: false }; } diff --git a/react/features/chat/components/AbstractMessageContainer.js b/react/features/chat/components/AbstractMessageContainer.js index ad1409c79..c05b0714e 100644 --- a/react/features/chat/components/AbstractMessageContainer.js +++ b/react/features/chat/components/AbstractMessageContainer.js @@ -39,7 +39,7 @@ export default class AbstractMessageContainer extends PureComponent

if (message.id === currentGroupParticipantId) { currentGrouping.push(message); } else { - groups.push(currentGrouping); + currentGrouping.length && groups.push(currentGrouping); currentGrouping = [ message ]; currentGroupParticipantId = message.id; diff --git a/react/features/chat/components/native/ChatMessage.js b/react/features/chat/components/native/ChatMessage.js index f46146a8b..993920b79 100644 --- a/react/features/chat/components/native/ChatMessage.js +++ b/react/features/chat/components/native/ChatMessage.js @@ -13,11 +13,6 @@ import AbstractChatMessage, { } from '../AbstractChatMessage'; import styles from './styles'; -/** - * Size of the rendered avatar in the message. - */ -const AVATAR_SIZE = 32; - /** * Formatter string to display the message timestamp. */ @@ -34,8 +29,6 @@ class ChatMessage extends AbstractChatMessage { */ render() { const { message } = this.props; - const timeStamp = getLocalizedDateFormatter( - new Date(message.timestamp)).format(TIMESTAMP_FORMAT); const localMessage = message.messageType === 'local'; // Style arrays that need to be updated in various scenarios, such as @@ -60,18 +53,12 @@ class ChatMessage extends AbstractChatMessage { return ( - { - - // Avatar is only rendered for remote messages. - !localMessage && this._renderAvatar() - } + { this._renderAvatar() } { - - // Display name is only rendered for remote - // messages. - !localMessage && this._renderDisplayName() + this.props.showDisplayName + && this._renderDisplayName() } { message.messageType === 'error' @@ -82,9 +69,7 @@ class ChatMessage extends AbstractChatMessage { : message.message } - - { timeStamp } - + { this.props.showTimestamp && this._renderTimestamp() } ); @@ -96,13 +81,12 @@ class ChatMessage extends AbstractChatMessage { * @returns {React$Element<*>} */ _renderAvatar() { - const { _avatarURL } = this.props; - return ( - + { this.props.showAvatar && + } ); } @@ -113,11 +97,26 @@ class ChatMessage extends AbstractChatMessage { * @returns {React$Element<*>} */ _renderDisplayName() { - const { message } = this.props; - return ( - { message.displayName } + { this.props.message.displayName } + + ); + } + + /** + * Renders the time at which the message was sent. + * + * @returns {React$Element<*>} + */ + _renderTimestamp() { + return ( + + { + getLocalizedDateFormatter( + new Date(this.props.message.timestamp) + ).format(TIMESTAMP_FORMAT) + } ); } diff --git a/react/features/chat/components/native/ChatMessageGroup.js b/react/features/chat/components/native/ChatMessageGroup.js index 31ca2b534..36d10534f 100644 --- a/react/features/chat/components/native/ChatMessageGroup.js +++ b/react/features/chat/components/native/ChatMessageGroup.js @@ -68,9 +68,19 @@ export default class ChatMessageGroup extends Component { * @param {Object} message - The chat message to render. * @returns {React$Element<*>} */ - _renderMessage({ item: message }) { + _renderMessage({ index, item: message }) { return ( - + ); } } diff --git a/react/features/chat/components/native/styles.js b/react/features/chat/components/native/styles.js index fc4ca2fb4..7a54d29e1 100644 --- a/react/features/chat/components/native/styles.js +++ b/react/features/chat/components/native/styles.js @@ -16,7 +16,8 @@ export default { * Wrapper View for the avatar. */ avatarWrapper: { - marginRight: 8 + marginRight: 8, + width: 32 }, /**