small fix

This commit is contained in:
Guilherme Gazzo 2018-02-16 15:11:10 -02:00
parent 69e04a4c26
commit 77d7f51f30
No known key found for this signature in database
GPG Key ID: 1F85C9AD922D0829
3 changed files with 12 additions and 7 deletions

View File

@ -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);
}

View File

@ -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() {

View File

@ -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, {