Chats: add submit button, fixes #356

better-thread-display
Alex Gleason 2020-09-06 17:43:16 -05:00
rodzic 024e9209af
commit 60402a7402
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 28 dodań i 6 usunięć

Wyświetl plik

@ -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() ? (
<div className='chat-box__send'>
<IconButton icon='send' size={16} onClick={this.sendMessage} />
</div>
) : (
<UploadButton onSelectFile={this.handleFiles} resetFileKey={resetFileKey} />
);
}
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()}
<UploadProgress active={isUploading} progress={uploadProgress*100} />
<div className='chat-box__actions simple_form'>
<UploadButton onSelectFile={this.handleFiles} resetFileKey={resetFileKey} />
{this.renderActionButton()}
<textarea
rows={1}
placeholder={intl.formatMessage(messages.placeholder)}

Wyświetl plik

@ -236,6 +236,10 @@
margin: 0;
}
.chat-box__send .icon-button {
top: 12px;
}
textarea {
width: 100%;
height: 100%;