Skip to content

Commit

Permalink
ImagePicker: Handle maxfiles correctly.
Browse files Browse the repository at this point in the history
Adds an option composeMenu.js to pass in a maxFiles number.

This is used to make sure the user can only select the correct
number of files subject to our max of 4.
  • Loading branch information
armaanahluwalia committed Sep 28, 2018
1 parent e212b51 commit 7a51356
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/compose/ComposeBox.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ class ComposeBox extends PureComponent<Props, State> {
onImageSelect={this.handleImageSelect}
disableCamera={draftImages && Object.keys(draftImages).length >= 4}
disableUpload={draftImages && Object.keys(draftImages).length >= 4}
maxFiles={4 - Object.keys(draftImages).length}
/>
</View>
<View style={styles.composeText}>
Expand Down
4 changes: 3 additions & 1 deletion src/compose/ComposeMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Props = {
onImageSelect: Object => void,
disableUpload?: boolean,
disableCamera?: boolean,
maxFiles?: number,
};

/**
Expand Down Expand Up @@ -76,13 +77,14 @@ class ComposeMenu extends PureComponent<Props> {

handleImageUpload = () => {
const { handleImagePickerResponse } = this;
const { maxFiles } = this.props;
ImagePicker.openPicker({
mediaType: 'photo',
multiple: true,
compressImageMaxWidth: 1600,
compressImageMaxHeight: 1600,
compressImageQuality: 0.7,
maxFiles: 4,
maxFiles,
})
.then(images => {
handleImagePickerResponse({
Expand Down

0 comments on commit 7a51356

Please sign in to comment.