From 00ca930d2e9abe6b51189292a60444d6bf9f13f1 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 29 Apr 2019 16:11:23 +0100 Subject: [PATCH] Extract actionable content check to helper --- .../views/messages/MessageActionBar.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/views/messages/MessageActionBar.js b/src/components/views/messages/MessageActionBar.js index fa020612c4..3fe3f74a9d 100644 --- a/src/components/views/messages/MessageActionBar.js +++ b/src/components/views/messages/MessageActionBar.js @@ -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 = ; + return true; } } + return false; + } + + render() { + let replyButton; + + if (this.isContentActionable()) { + replyButton = ; + } + return
{replyButton}