diff --git a/app/containers/MessageActions.js b/app/containers/MessageActions.js index e362c69d..6a2de4b4 100644 --- a/app/containers/MessageActions.js +++ b/app/containers/MessageActions.js @@ -18,6 +18,7 @@ import { } from '../actions/messages'; import { showToast } from '../utils/info'; +const returnAnArray = obj => obj || []; @connect( state => ({ showActions: state.messages.showActions, @@ -171,11 +172,11 @@ export default class MessageActions extends React.Component { } setPermissions(permissions) { - this.hasEditPermission = permissions['edit-message'] + this.hasEditPermission = returnAnArray(permissions['edit-message']) .some(item => this.mergedRoles.indexOf(item) !== -1); - this.hasDeletePermission = permissions['delete-message'] + this.hasDeletePermission = returnAnArray(permissions['delete-message']) .some(item => this.mergedRoles.indexOf(item) !== -1); - this.hasForceDeletePermission = permissions['force-delete-message'] + this.hasForceDeletePermission = returnAnArray(permissions['force-delete-message']) .some(item => this.mergedRoles.indexOf(item) !== -1); } diff --git a/app/containers/status.js b/app/containers/status.js index 297fa2c2..55a78fcc 100644 --- a/app/containers/status.js +++ b/app/containers/status.js @@ -30,7 +30,7 @@ export default class Status extends React.Component { get status() { const userId = this.props.id; - return this.props.activeUsers && this.props.activeUsers[userId] || 'offline'; + return (this.props.activeUsers && this.props.activeUsers[userId]) || 'offline'; } render() { diff --git a/app/presentation/RoomItem.js b/app/presentation/RoomItem.js index b39a0cb6..946796b7 100644 --- a/app/presentation/RoomItem.js +++ b/app/presentation/RoomItem.js @@ -160,7 +160,8 @@ export default class RoomItem extends React.PureComponent { userMentions: PropTypes.number, id: PropTypes.string, onPress: PropTypes.func, - customEmojis: PropTypes.object + customEmojis: PropTypes.object, + user: PropTypes.object } get icon() { @@ -193,10 +194,13 @@ export default class RoomItem extends React.PureComponent { const msg = `${ prefix }${ lastMessage.msg.replace(/[\n\t\r]/igm, '') }`; + const maxChars = 35; + + if (alert) { - return `**${ msg.slice(0, 30) }${ msg.replace(/:[a-z0-9]+:/gi, ':::').length > 30 ? '...' : '' }**`; + return `**${ msg.slice(0, maxChars) }${ msg.replace(/:[a-z0-9]+:/gi, ':::').length > maxChars ? '...' : '' }**`; } - return msg; + return `${ msg.slice(0, maxChars) }${ msg.replace(/:[a-z0-9]+:/gi, ':::').length > maxChars ? '...' : '' }`; } formatDate = date => moment(date).calendar(null, {