diff --git a/app/soapbox/features/chats/components/chat_box.js b/app/soapbox/features/chats/components/chat_box.js index bde2f9dbf..ee2b7cd20 100644 --- a/app/soapbox/features/chats/components/chat_box.js +++ b/app/soapbox/features/chats/components/chat_box.js @@ -65,16 +65,22 @@ class ChatBox extends ImmutablePureComponent { }; } - sendMessage = () => { - const { dispatch, chatId } = this.props; - const { content, attachment, isUploading } = this.state; + canSubmit = () => { + const { content, attachment } = this.state; const conds = [ content.length > 0, attachment, ]; - if (!isUploading && conds.some(c => c)) { + return conds.some(c => c); + } + + sendMessage = () => { + const { dispatch, chatId } = this.props; + const { isUploading } = this.state; + + if (this.canSubmit() && !isUploading) { const params = this.getParams(); dispatch(sendChatMessage(chatId, params)); @@ -167,9 +173,21 @@ class ChatBox extends ImmutablePureComponent { ); } + renderActionButton = () => { + const { resetFileKey } = this.state; + + return this.canSubmit() ? ( +
+ +
+ ) : ( + + ); + } + render() { const { chatMessageIds, chatId, intl } = this.props; - const { content, isUploading, uploadProgress, resetFileKey } = this.state; + const { content, isUploading, uploadProgress } = this.state; if (!chatMessageIds) return null; return ( @@ -178,7 +196,7 @@ class ChatBox extends ImmutablePureComponent { {this.renderAttachment()}
- + {this.renderActionButton()}