Extract actionable content check to helper

This commit is contained in:
J. Ryan Stinnett 2019-04-29 16:11:23 +01:00
parent 7f62cdf124
commit 00ca930d2e

View file

@ -87,15 +87,13 @@ export default class MessageActionBar extends React.PureComponent {
this.onFocusChange(true);
}
render() {
isContentActionable() {
const { mxEvent } = this.props;
const { status: eventStatus } = mxEvent;
// status is SENT before remote-echo, null after
const isSent = !eventStatus || eventStatus === EventStatus.SENT;
let replyButton;
if (isSent && mxEvent.getType() === 'm.room.message') {
const content = mxEvent.getContent();
if (
@ -103,13 +101,23 @@ export default class MessageActionBar extends React.PureComponent {
content.msgtype !== 'm.bad.encrypted' &&
content.hasOwnProperty('body')
) {
replyButton = <span className="mx_MessageActionBar_replyButton"
title={_t("Reply")}
onClick={this.onReplyClick}
/>;
return true;
}
}
return false;
}
render() {
let replyButton;
if (this.isContentActionable()) {
replyButton = <span className="mx_MessageActionBar_replyButton"
title={_t("Reply")}
onClick={this.onReplyClick}
/>;
}
return <div className="mx_MessageActionBar">
{replyButton}
<span className="mx_MessageActionBar_optionsButton"