Extract actionable content check to helper

pull/21833/head
J. Ryan Stinnett 2019-04-29 16:11:23 +01:00
parent 7f62cdf124
commit 00ca930d2e
1 changed files with 15 additions and 7 deletions

View File

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