diff --git a/app/containers/message/index.js b/app/containers/message/index.js index 931d5777..8b01fe05 100644 --- a/app/containers/message/index.js +++ b/app/containers/message/index.js @@ -66,12 +66,40 @@ export default class Message extends React.Component { this.props.errorActionsShow(JSON.parse(JSON.stringify(item))); } - isDeleted() { - return this.props.item.t === 'rm'; + getInfoMessage() { + let message = ''; + const messageType = this.props.item.t; + + if (messageType === 'rm') { + message = 'Message removed'; + } else if (messageType === 'uj') { + message = 'Has joined the channel.'; + } else if (messageType === 'r') { + message = `Room name changed to: ${ this.props.item.msg } by ${ this.props.item.u.username }`; + } else if (messageType === 'message_pinned') { + message = 'Message pinned'; + } else if (messageType === 'ul') { + message = 'Has left the channel.'; + } else if (messageType === 'ru') { + message = `User ${ this.props.item.msg } removed by ${ this.props.item.u.username }`; + } else if (messageType === 'au') { + message = `User ${ this.props.item.msg } added by ${ this.props.item.u.username }`; + } else if (messageType === 'user-muted') { + message = `User ${ this.props.item.msg } muted by ${ this.props.item.u.username }`; + } else if (messageType === 'user-unmuted') { + message = `User ${ this.props.item.msg } unmuted by ${ this.props.item.u.username }`; + } + + return message; } - isPinned() { - return this.props.item.t === 'message_pinned'; + isInfoMessage() { + return ['r', 'au', 'ru', 'ul', 'uj', 'rm', 'user-muted', 'user-unmuted', 'message_pinned'].includes(this.props.item.t); + } + + + isDeleted() { + return this.props.item.t === 'rm'; } hasError() { @@ -97,10 +125,8 @@ export default class Message extends React.Component { } renderMessageContent() { - if (this.isDeleted()) { - return Message removed; - } else if (this.isPinned()) { - return Message pinned; + if (this.isInfoMessage()) { + return {this.getInfoMessage()}; } return ; }