allow empty message when they have attachments

pull/1387/head
Audric Ackermann 5 years ago
parent c5927cfc4b
commit b46ed237b3
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1275,7 +1275,11 @@
},
"messageBodyTooLong": {
"message": "Message body is too long.",
"description": "Shown if the user tries to send more than 64kb of text"
"description": "Shown if the user tries to send more than MAX_MESSAGE_BODY_LENGTH chars"
},
"messageBodyMissing": {
"message": "Please enter a message body.",
"description": "Shown if the user tries to send an empty message (and no attachments)"
},
"unblockToSend": {
"message": "Unblock this contact to send a message.",

@ -325,13 +325,14 @@ export class SessionCompositionBox extends React.Component<Props, State> {
private async onSendMessage() {
const messagePlaintext = this.parseEmojis(this.state.message);
if (!messagePlaintext) {
// Verify message length
const msgLen = messagePlaintext?.length || 0;
if (msgLen > window.CONSTANTS.MAX_MESSAGE_BODY_LENGTH) {
ToastUtils.pushMessageBodyTooLong();
return;
}
// Verify message length
const msgLen = messagePlaintext.length;
if (msgLen === 0 || msgLen > window.CONSTANTS.MAX_MESSAGE_BODY_LENGTH) {
if (msgLen === 0 && this.state.stagedAttachments?.length === 0) {
ToastUtils.pushMessageBodyMissing();
return;
}
const { quotedMessageProps } = this.props;

@ -57,3 +57,19 @@ export function pushMaximumAttachmentsError() {
id: 'maximumAttachments',
});
}
export function pushMessageBodyTooLong() {
window.pushToast({
title: window.i18n('messageBodyTooLong'),
type: 'error',
id: 'messageBodyTooLong',
});
}
export function pushMessageBodyMissing() {
window.pushToast({
title: window.i18n('messageBodyMissing'),
type: 'error',
id: 'messageBodyMissing',
});
}

Loading…
Cancel
Save