Skip to content

Commit

Permalink
Add error message for image being too small
Browse files Browse the repository at this point in the history
  • Loading branch information
tgolen committed Jul 26, 2022
1 parent 1464dbe commit 6c50384
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class AttachmentModal extends PureComponent {
this.state = {
isModalOpen: false,
isAttachmentInvalid: false,
attachmentInvalidReasonTitle: null,
attachmentInvalidReason: null,
file: null,
sourceURL: props.sourceURL,
modalType: CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE,
Expand Down Expand Up @@ -139,13 +141,17 @@ class AttachmentModal extends PureComponent {
if (file.size > CONST.API_MAX_ATTACHMENT_SIZE) {
this.setState({
isAttachmentInvalid: true,
attachmentInvalidReasonTitle: 'attachmentPicker.attachmentTooLarge',
attachmentInvalidReason: 'attachmentPicker.sizeExceeded',
});
return false;
}

if (file.size < CONST.API_MIN_ATTACHMENT_SIZE) {
this.setState({
isAttachmentInvalid: true,
attachmentInvalidReasonTitle: 'attachmentPicker.attachmentTooSmall',
attachmentInvalidReason: 'attachmentPicker.sizeNotMet',
});
return false;
}
Expand Down Expand Up @@ -238,11 +244,11 @@ class AttachmentModal extends PureComponent {
</Modal>

<ConfirmModal
title={this.props.translate('attachmentPicker.attachmentTooLarge')}
title={this.state.attachmentInvalidReasonTitle && this.props.translate(this.state.attachmentInvalidReasonTitle)}
onConfirm={this.closeConfirmModal}
onCancel={this.closeConfirmModal}
isVisible={this.state.isAttachmentInvalid}
prompt={this.props.translate('attachmentPicker.sizeExceeded')}
prompt={this.state.attachmentInvalidReason && this.props.translate(this.state.attachmentInvalidReason)}
confirmText={this.props.translate('common.close')}
shouldShowCancelButton={false}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ export default {
chooseFromGallery: 'Choose from gallery',
chooseDocument: 'Choose document',
attachmentTooLarge: 'Attachment too large',
attachmentTooSmall: 'Attachment too small',
sizeExceeded: 'Attachment size is larger than 50 MB limit.',
sizeNotMet: 'Attachment size is less than the 240 byte minimum requirement',
},
composer: {
noExtentionFoundForMimeType: 'No extension found for mime type',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ export default {
chooseFromGallery: 'Elegir de la galería',
chooseDocument: 'Elegir documento',
attachmentTooLarge: 'Archivo adjunto demasiado grande',
attachmentTooSmall: 'Attachment too small',
sizeExceeded: 'El archivo adjunto supera el límite de 50 MB.',
sizeNotMet: 'Attachment size is less than the 240 byte minimum requirement',
},
composer: {
noExtentionFoundForMimeType: 'No se encontró una extension para este tipo de contenido',
Expand Down

0 comments on commit 6c50384

Please sign in to comment.